-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
91 lines (86 loc) · 2.06 KB
/
Copy pathwebpack.config.js
File metadata and controls
91 lines (86 loc) · 2.06 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
79
80
81
82
83
84
85
86
87
88
89
90
91
process.traceDeprecation = true;
module.exports = (env, argv) => {
var development_mode = (argv.mode === 'development');
var webpack = require('webpack');
var UglifyJsPlugin = require("uglifyjs-webpack-plugin");
var MiniCssExtractPlugin = require("mini-css-extract-plugin");
var OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
var node_dir = __dirname + '/node_modules';
var output_dir = __dirname +"/app/production";
var config = {
mode: process.env.NODE_ENV,
context: __dirname,
entry: "./app/js/index.js",
devtool: (development_mode ? 'source-map' : false),
output: {
path: output_dir,
filename: (development_mode ? 'index.js' : 'index.min.js')
},
module: {
rules: [
{
test: require.resolve('jquery'),
exclude: [
/node_modules/
],
use: 'expose-loader?jQuery!expose?$'
},
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
url: false,
sourceMap: true
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true
}
}
]
},
{
// load external resources (ie Google fonts)
test: /.(gif|jpg|png|woff(2)?|eot|ttf|svg)(\?[a-z0-9=\.]+)?$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]',
limit: 10000000
}
}
}
]
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery"
}),
new MiniCssExtractPlugin({
path: output_dir,
filename: (development_mode ? 'index.css' : 'index.min.css'),
sourceMap: true
})
],
optimization: {
minimize: !development_mode,
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: true
}),
new OptimizeCSSAssetsPlugin({})
]
},
};
return config;
}