-
Notifications
You must be signed in to change notification settings - Fork 24
/
webpack.config.js
92 lines (78 loc) · 1.77 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
/*
* @title Webpack Config
*/
// Dependencies
import webpack from 'webpack';
// Config
import { paths } from "./gulpfile.babel.js/config";
const path = require('path');
// Plugins
var WebpackNotifierPlugin = require('webpack-notifier');
const webpackConfig = {
mode: process.env.NODE_ENV ? "production" : "development",
entry: {
app: paths.scripts.src
},
output: {
filename: '[name].js',
},
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'all',
minSize: 0
}
}
}
},
module: {
rules: [
{
test: /^(?!.*\.{test,min}\.js$).*\.js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
{
test: /\.s?css$/,
include: /node_modules/,
use: [
'style-loader',
'css-loader',
'sass-loader',
],
}
]
},
plugins: [
// ensure that we get a production build of any dependencies
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
}),
new WebpackNotifierPlugin({
skipFirstNotification: true
})
],
resolve: {
alias: {
Modules: path.resolve(__dirname, 'src/modules/'),
Components: path.resolve(__dirname, 'src/scripts/components/'),
Utils: path.resolve(__dirname, 'src/scripts/utils/'),
}
}
};
if (process.env.NODE_ENV === 'production') {
// console.log('Welcome to production');
webpackConfig.devtool = 'source-map';
}
if (process.env.NODE_ENV === 'development') {
// console.log('Welcome to development');
}
module.exports = webpackConfig;