-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
75 lines (71 loc) · 2.16 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
const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const { compact } = require('lodash');
const { NODE_ENV } = process.env;
const isProduction = NODE_ENV === 'production';
const webpackConfig = {
devtool: isProduction ? 'source-map' : 'cheap-module-eval-source-map',
entry: compact([
!isProduction && 'webpack-hot-middleware/client',
'whatwg-fetch',
'./src/client/index.tsx'
]),
mode: isProduction ? 'production' : 'development',
module: {
rules: [
{
test: /\.(t|j)sx?$/,
include: /src/,
exclude: /node_modules/,
loader: [
{
loader: 'babel-loader',
options: {
babelrc: false,
plugins: ['react-hot-loader/babel', '@babel/plugin-syntax-dynamic-import']
}
},
{
loader: 'awesome-typescript-loader',
options: {
module: 'es6',
silent: true,
transpileOnly: true
}
}
]
},
{
test: /\.js$/,
loader: 'source-map-loader',
enforce: 'pre'
},
{ test: /\.(png|jpg|gif|jpeg)$/, loader: 'url-loader?limit=8192' },
{ test: /\.css$/, loader: ['style-loader', 'css-loader'] },
{ test: /\.(eot|svg|ttf|woff|woff2)$/, loader: 'file-loader?name=public/fonts/[name].[ext]' }
]
},
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/static/'
},
plugins: compact([
!isProduction && new webpack.HotModuleReplacementPlugin(),
new webpack.EnvironmentPlugin({ NODE_ENV: 'development', PARSER: null, FIREBASE_DB: null }),
new CopyWebpackPlugin([{ from: 'static' }]),
new webpack.IgnorePlugin(/^canvas$/),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), // Ignore all locale files of moment.js
]),
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
alias: {
// https://github.com/lodash/lodash/issues/3079
'./lodash.min': 'lodash/lodash.js',
}
},
stats: isProduction ? 'minimal' : 'normal',
target: 'web'
};
export default webpackConfig;