This repository has been archived by the owner on Jul 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
93 lines (81 loc) · 2.2 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const path = require('path');
const { SourceMapDevToolPlugin } = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const SplitByPathPlugin = require('webpack-split-by-path');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const ENV = process.env.NODE_ENV;
const isProd = ENV === 'production' || ENV === 'prod';
module.exports = {
entry: {
// polyfills: ['babel-polyfill'],
// polyfills must be first for async/await etc.
app: ['babel-polyfill', path.join(__dirname, './client/index.js')],
},
context: __dirname,
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].[hash].js',
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
options: {
presets: ['env'],
ignore: [
'node_modules',
'assets',
'test',
'spec',
],
},
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader!sass-loader',
}),
},
],
},
plugins: [
new SplitByPathPlugin([{
name: 'vendor',
path: path.join(__dirname, 'node_modules'),
}]),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'client', 'index.html'),
chunksSortMode: 'dependency',
}),
new ExtractTextPlugin({
filename: 'css/[name].[hash].css',
disable: !isProd,
}),
new CopyWebpackPlugin([{ from: path.join(__dirname, 'assets') }]),
// exclude vendor files from being source mapped
new SourceMapDevToolPlugin({
filename: '[file].map',
exclude: /vendor\.(.+)\.js/,
}),
new ProgressBarPlugin(),
],
resolve: {
modules: ['node_modules', path.resolve(process.cwd(), 'common')],
extensions: ['.js', 'scss'],
},
devServer: {
contentBase: path.join(process.cwd(), 'dist'),
clientLogLevel: 'info',
port: 8080,
inline: true,
historyApiFallback: false,
watchOptions: {
aggregateTimeout: 300,
poll: 500,
},
},
};