-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
74 lines (64 loc) · 1.69 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
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const babel = require('./webpack/babel');
const devServer = require('./webpack/dev-server');
const fonts = require('./webpack/fonts');
const images = require('./webpack/images');
const html = require('./webpack/html');
const optimization = require('./webpack/optimization');
const eslint = require('./webpack/eslint');
const isProd = process.env.NODE_ENV === 'production';
const PATH = {
src: path.join(__dirname, 'src'),
build: path.join(__dirname, 'build')
};
const plugins = [
new HtmlWebPackPlugin({
template: `${PATH.src}/index.ejs`,
title: 'WRRench',
favicon: `${PATH.src}/img/favicon.ico`
})
];
const rules = [babel(), html(), fonts(), images(), eslint()];
const common = {
entry: {
app: ['./src/index.js']
},
output: {
path: PATH.build,
filename: 'bundle.[hash].js',
chunkFilename: '[name].chunk.[hash].js',
publicPath: isProd ? '/WRRench/' : '/'
},
resolve: {
extensions: ['.js', '.jsx', '.json'],
modules: ['node_modules'],
alias: {
app: path.resolve(__dirname, 'app'),
components: path.resolve(__dirname, 'components'),
src: path.resolve(__dirname, 'src')
}
},
module: {
rules
},
plugins
};
const prodConf = merge([common, optimization()]);
const devConf = merge([
common,
{
devtool: 'cheap-module-source-map',
optimization: {
namedModules: true
},
performance: {
hints: false
},
plugins: [new webpack.HotModuleReplacementPlugin()]
},
devServer()
]);
module.exports = () => (isProd ? prodConf : devConf);