-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
93 lines (90 loc) · 3.35 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
const path = require('path')
const glob = require('glob')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const autoprefixer = require('autoprefixer')
const srcDir = './src'
const entryObj = {
'svg-japan' : [ 'babel-polyfill', 'events-polyfill', path.resolve(__dirname, srcDir, 'index.js') ],
'svg-japan.nopolyfill' : [ path.resolve(__dirname, srcDir, 'index.js') ]
//'svg-japan': [ path.resolve(__dirname, srcDir, 'index.scss') ]
}
const isDevelopment = process.env.NODE_ENV === 'development'
module.exports = {
mode: isDevelopment ? 'development' : 'production',
devtool: isDevelopment ? 'inline-source-map' : false,
entry: entryObj,
output: {
path: path.join(__dirname, 'dist'),
filename: isDevelopment ? "[name].js" : "[name].min.js"
},
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
exclude: /(node_modules|assets)/,
loader: 'eslint-loader',
options: {
fix: true
}
},
{
test: /\.js$/,
exclude: /(node_modules|assets)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
{
test: /\.(sa|sc|c)ss$/,
exclude: /(node_modules|assets)/,
use: [
// During development, CSS is bundled with JS, and it is divided and output for production.
// isDevelopment ? 'style-loader' : MiniCssExtractPlugin.loader,
// Always split output of JS and CSS
// MiniCssExtractPlugin.loader,
'style-loader',
{
loader: 'css-loader',
options: {
// During development, CSS is bundled with JS, and it is divided and output for production.
// url: isDevelopment ? true : false,
url: false,
sourceMap: isDevelopment ? true : false,
// 2 => postcss-loader, sass-loader
//importLoaders: 2
}
},
{
loader: 'postcss-loader',
options: {
sourceMap: isDevelopment ? true : false,
postcssOptions: {
plugins: () => [ autoprefixer({ grid: true }) ]
}
}
},
{
loader: 'sass-loader',
options: {
sourceMap: isDevelopment ? true : false
}
}
]
}
]
},/*
plugins: [
new MiniCssExtractPlugin({
filename: './[name].css',
chunkFilename: '[id].css'
})
],*/
watch: isDevelopment ? true : false,
watchOptions: {
ignored: [ 'assets', 'node_modules' ]
}
};