-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.babel.js
89 lines (85 loc) · 2.02 KB
/
webpack.config.babel.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
import path from 'path';
import { LoaderOptionsPlugin } from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import FlowBabelWebpackPlugin from 'flow-babel-webpack-plugin';
const production = process.env.NODE_ENV === 'production';
let config = {
entry: {
'app': [
'babel-polyfill',
'react-hot-loader/patch',
path.join(__dirname, './src/index.jsx'),
]
},
output: {
path: path.join(__dirname, './public'),
filename: production ? 'app.[hash].js' : 'app.js',
sourceMapFilename: 'app.js.map',
publicPath: '/',
},
resolve: {
extensions: ['.js', '.jsx'],
modules: [
path.resolve('./src'),
path.resolve('./resources'),
path.resolve('./node_modules'),
],
},
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: [
/node_modules/,
/src\/server/,
],
},
{
test: /\.css$/,
loaders: [
'style-loader', {
loader: 'css-loader',
options: {
modules: true,
localIdentName: production ? '[hash:base64]' : '[name]-[local]-[hash:base64:5]',
},
},
'postcss-loader',
],
},
{
test: /\.(gif|jpe?g|png|ico)$/,
loader: 'url-loader',
options: {
limit: 25000,
},
},
{
test: /\.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
loader: 'file-loader?name=fonts/[name].[ext]',
options: {
publicPath: '/',
},
},
],
},
plugins: [
new HtmlWebpackPlugin({
filename: path.join(__dirname, './public/index.html'),
template: path.join(__dirname, './src/index.html'),
}),
new LoaderOptionsPlugin({
minimize: production,
sourceMap: !production,
}),
],
devServer: {
contentBase: path.join(__dirname, './public'),
port: 8080,
},
};
if (!production) {
config.plugins.push(new FlowBabelWebpackPlugin());
}
module.exports = config;