This repository has been archived by the owner on Jul 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
65 lines (60 loc) · 1.54 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
const path = require('path');
const {
addPlugins, createConfig, entryPoint, env, setOutput, sourceMaps, defineConstants, webpack,
customConfig,
} = require('@webpack-blocks/webpack2');
const babel = require('@webpack-blocks/babel6');
const WebpackMd5Hash = require('webpack-md5-hash');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const outputPath = path.resolve(__dirname, 'dist');
const publicPath = '/';
const config = createConfig([
setOutput({
filename: '[name].[hash].js',
path: outputPath,
publicPath,
}),
defineConstants({
'process.env.NODE_ENV': process.env.NODE_ENV,
}),
babel(),
addPlugins([
new HtmlWebpackPlugin({
filename: 'index.html',
template: path.join(__dirname, 'templates/index.html'),
}),
]),
customConfig({
resolve: {
extensions: ['.js', '.jsx', '.json'],
modules: [
path.resolve(__dirname, 'src'),
'node_modules',
],
},
}),
env('development', [
entryPoint([
'webpack-hot-middleware/client',
'./src/index',
]),
sourceMaps(),
addPlugins([
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
]),
]),
env('production', [
entryPoint('./src/index'),
setOutput({
filename: '[name].[chunkHash].js',
path: outputPath,
publicPath,
}),
addPlugins([
new WebpackMd5Hash(),
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false, drop_console: false } }),
]),
]),
]);
module.exports = config; // eslint-disable-line