forked from fullcalendar/fullcalendar-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
57 lines (52 loc) · 1.47 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
const path = require('path')
const glob = require('glob')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
module.exports = (env, options) => {
let isProduction = options.mode === 'production'
return {
mode: 'development', // unless overridden by command-line flag
devtool: isProduction ? false : 'inline-source-map',
entry: buildEntryMap(),
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css'
})
],
optimization: {
// https://github.com/webpack-contrib/mini-css-extract-plugin#minimizing-for-production
minimizer: isProduction ? [ new OptimizeCSSAssetsPlugin({}) ] : [],
},
module: {
rules: [
{
test: /\.scss$/,
use: [
{ loader: MiniCssExtractPlugin.loader },
{ loader: 'css-loader' },
{ loader: 'sass-loader' }
]
},
{
test: /\.(png|jpg|gif)$/i, // TODO: better to use src/styles/images/* instead
use: [
{ loader: 'url-loader' }
]
}
]
},
output: {
path: path.join(__dirname, 'assets'),
filename: '[name].js' // will produce a JS file we won't use
}
}
}
function buildEntryMap() {
let map = {}
let jsPaths = glob.sync('./src/*.js')
for (let jsPath of jsPaths) {
let name = path.basename(jsPath, '.js')
map[name] = jsPath
}
return map
}