-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathwebpack.config.babel.js
More file actions
81 lines (73 loc) · 1.58 KB
/
webpack.config.babel.js
File metadata and controls
81 lines (73 loc) · 1.58 KB
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
// Dependencies
import webpack from 'webpack';
import path from 'path';
import ChunksPlugin from 'webpack-split-chunks';
// Environment
const isDevelopment = process.env.NODE_ENV !== 'production';
// Paths
const PATHS = {
index: path.join(__dirname, 'src/index'),
build: path.join(__dirname, 'src/public'),
src: path.join(__dirname, 'src')
};
const getDevtool = () => 'cheap-module-eval-source-map';
const getEntry = () => {
const entry = [PATHS.index];
if (isDevelopment) {
entry.push('webpack-hot-middleware/client?reload=true');
}
return entry;
};
const getOutput = () => ({
path: PATHS.build,
publicPath: '/',
filename: '[name].bundle.js'
});
const getPlugins = () => {
const plugins = [
new ChunksPlugin({
to: 'vendor',
test: /node_modules/
})
];
if (isDevelopment) {
plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin()
);
} else {
plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: {
screw_ie8: true,
warnings: false
}
})
);
}
return plugins;
};
const getLoaders = () => ({
loaders: [
{
test: /\.js?$/,
loaders: ['babel-loader'],
include: PATHS.src
},
{
test: /(\.css)$/,
loaders: ['style-loader', 'css-loader']
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=image/svg+xml'
}
]
});
export default {
devtool: getDevtool(),
entry: getEntry(),
output: getOutput(),
plugins: getPlugins(),
module: getLoaders()
};