-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
executable file
·78 lines (73 loc) · 2.03 KB
/
webpack.config.js
File metadata and controls
executable file
·78 lines (73 loc) · 2.03 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
const notifier = require('node-notifier');
const path = require('path');
const webpack = require('webpack');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
module.exports = (env, argv) => {
const isProd = argv.mode === 'production';
const mode = isProd ? 'production' : 'development';
process.env.BABEL_ENV = mode;
process.env.NODE_ENV = mode;
return {
mode,
devtool: !isProd ? 'cheap-module-source-map' : false,
entry: path.resolve('assets/src/js/index.js'),
output: {
filename: `[name]${isProd ? '.min' : ''}.js`,
chunkFilename: `[id]${isProd ? '.[chunkhash].min' : ''}.js`,
path: path.resolve('assets/build/'),
},
plugins: [
new webpack.HashedModuleIdsPlugin(),
new FriendlyErrorsWebpackPlugin({
onErrors(severity, errors) {
if (severity !== 'error') {
return;
}
const error = errors[0];
notifier.notify({
title: error.name,
message: error.message || '',
subtitle: error.file || '',
icon: 'icon.png',
});
},
}),
],
module: {
rules: [
{
oneOf: [
{
test: /\.js$/,
include: path.resolve('assets/src/js/'),
use: [
{
loader: 'babel-loader',
},
{
loader: 'eslint-loader',
options: {
fix: true,
format: 'pretty',
},
},
],
},
{
include: path.resolve('assets/src/'),
loader: 'file-loader',
options: {
outputPath: path.resolve('assets/build/'),
name: `[name]${isProd ? '.[hash]' : ''}.[ext]`,
},
},
],
},
],
},
watchOptions: {
ignored: /(node_modules|bower_components|jspm_packages)/,
poll: 1000,
},
};
};