-
Notifications
You must be signed in to change notification settings - Fork 17
/
webpack.config.js
65 lines (61 loc) · 2.03 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
/**
* Run webpack with: ./node_modules/.bin/webpack --config webpack.config.js
*/
const path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpack = require("webpack");
const devMode = process.env.DJANGO_CONFIGURATION == 'Dev';
const distPath = path.resolve(__dirname, 'oldp/assets/static/dist');
console.log('devMode: ', devMode);
module.exports = {
mode : devMode ? 'development' : 'production',
// mode: 'production',
devtool: 'source-map',
entry : {
main: './oldp/assets/static/js/main.js',
// annotate: './oldp/assets/static-global/js/annotate.js'
},
output : {
filename : '[name].js',
path : distPath
},
// optimization: {
// splitChunks: {
// // include all types of chunks
// chunks: 'all'
// }
// },
module : {
rules : [
{
test: /\.js$/,
exclude: /node_modules/,
// use: "babel-loader"
},
{
test: /\.scss$/,
use: [
{ loader: MiniCssExtractPlugin.loader, options: {} },
{ loader: 'css-loader', options: { url: false, sourceMap: devMode, minimize: true } },
{ loader: 'sass-loader', options: { sourceMap: true, outputStyle: 'compressed', minimize: true } }
],
}
]
},
plugins: [
new CleanWebpackPlugin(distPath, {} ),
new MiniCssExtractPlugin({
filename: "style.css"
}),
new CopyWebpackPlugin([
// TODO load with file-loader automatically
{ from: './node_modules/font-awesome/fonts', to: distPath + '/fonts/font-awesome'},
{ from: './node_modules/jquery-ui/themes/base/images', to: distPath + '/images'},
])
],
watchOptions: {
ignored: /node_modules/
}
};