This repository has been archived by the owner on Feb 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathwebpack.config.js
105 lines (95 loc) · 2.24 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
94
95
96
97
98
99
100
101
102
103
104
105
var path = require('path')
var BundleTracker = require('webpack-bundle-tracker')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
const extractSass = new ExtractTextPlugin({
filename: '[name].[hash].css',
})
var production = process.env.NODE_ENV == 'production'
var cfg = {
context: __dirname,
mode: production ? 'production' : 'development',
/*
pages:
- index (/)
- mrsrequest (/demande)
- contact (/contact)
- FAQ (/faq)
- legal (/legal)
- statistics (/stats)
base.html:
- header
- footer
*/
entry: {
base: ['babel-polyfill', './src/mrs/static/js/base'],
iframe: ['./src/mrs/static/js/iframe'],
crudlfap: [
'babel-polyfill',
'whatwg-fetch',
'./src/mrs/static/js/crudlfap',
'./node_modules/c3/c3.css',
'./node_modules/mrsmaterialize/sass/materialize.scss',
],
mrsbootstrap: [
'./src/mrs/static/scss/mrs.scss',
],
mrsindex: [
'countup.js', './src/mrs/static/js/mrsindex',
],
mrsfaq: [
'./src/mrs/static/js/mrsfaq',
],
},
output: {
path: path.resolve('./src/mrs/static/webpack_bundles/'),
filename: '[name].[hash].js',
pathinfo: false
},
plugins: [
new BundleTracker({filename: './webpack-stats.json'}),
extractSass
],
devtool: 'source-map',
module: {
rules: [
{
test: /\.js$/,
exclude: /(turbolinks)/,
use: {
loader: 'babel-loader',
options: {
presets: ['stage-2', 'babel-preset-env'],
plugins: ['transform-es2015-arrow-functions'],
sourceMap: true
}
}
},
{
test: /\.s?(a|c)ss$/,
use: extractSass.extract({
use: [{
loader: 'css-loader', options: {
sourceMap: true
}
}, {
loader: 'sass-loader', options: {
sourceMap: true
}
}]
})
}
]
},
optimization: {
removeAvailableModules: false,
removeEmptyChunks: false,
splitChunks: false,
}
}
if (production) {
cfg.plugins.push(new UglifyJSPlugin({
sourceMap: true
}))
}
module.exports = cfg