-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
95 lines (94 loc) · 2.58 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
const HtmlWebpackPlugin = require('html-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const webpack = require('webpack');
const path = require('path');
module.exports = env => ({
entry: {
ui: './src/ui/index.tsx',
},
mode: env.production ? 'production' : 'development',
output: {
path: path.resolve(__dirname, './out/ui'),
filename: '[name].bundle.js',
},
resolve: {
extensions: ['.mjs', '.ts', '.tsx', '.js', '.jsx'],
alias: {
common: path.resolve(__dirname, 'src/common'),
ui: path.resolve(__dirname, 'src/ui'),
},
},
devServer: {
contentBase: path.resolve(__dirname, '../dist/ui'),
hot: true,
port: 9000,
disableHostCheck: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
},
optimization: {
minimizer: [
new TerserPlugin({
cache: true,
parallel: true,
sourceMap: true,
terserOptions: {
compress: {
inline: false,
},
},
}),
],
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.(js|jsx|ts|tsx)$/,
exclude: /(node_modules)/,
loader: 'babel-loader',
},
{
test: /\.(png|svg|jpg|gif)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 100192,
},
},
],
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.ttf$/,
use: ['file-loader'],
},
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader',
},
],
},
plugins: [
new HtmlWebpackPlugin({
title: 'Waypoint',
template: require('html-webpack-template'),
appMountId: 'root',
inject: false,
favicon: './icons/icon.png',
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
PRODUCTION: env.production === true,
}),
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
],
});