-
Notifications
You must be signed in to change notification settings - Fork 17
/
webpack.config.js
141 lines (139 loc) · 3.85 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
const path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const IgnoreEmitPlugin = require('ignore-emit-webpack-plugin');
const TerserPlugin = require("terser-webpack-plugin");
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const isProduction = process.env.NODE_ENV === 'production';
const mode = isProduction ? 'production' : 'development';
const StylelintPlugin = require('stylelint-webpack-plugin');
if (process.env.NODE_ENV !== 'production') {
console.log('Looks like we are in development mode!');
}
console.warn(isProduction, process.env.NODE_ENV, mode);
module.exports = [
{
name: 'scripts',
mode: mode,
entry: {
'scripts': './Swift/Files/Templates/Designs/Swift/Assets/_src/js/swift.js'
},
output: {
path: path.resolve(__dirname, 'Swift','Files','Templates','Designs','Swift','Assets','js'),
filename: '[name].js'
},
module: {
rules: [
{
test: /\.js?$/,
loader: 'babel-loader'
}
]
},
optimization: {
minimize: isProduction,
minimizer: [
new TerserPlugin({
terserOptions: {
mangle: true,
format: {
comments: false,
}
},
})
]
}
},
{
name: 'modules',
mode: mode,
entry: {
'swiffy-slider': './Swift/Files/Templates/Designs/Swift/Assets/_src/js/modules/swiffy-slider.js',
'plyr': './Swift/Files/Templates/Designs/Swift/Assets/_src/js/modules/plyr.js',
'aos': './Swift/Files/Templates/Designs/Swift/Assets/_src/js/modules/aos.js',
'flatpickr': './Swift/Files/Templates/Designs/Swift/Assets/_src/js/modules/flatpickr.js',
'htmx': './Swift/Files/Templates/Designs/Swift/Assets/_src/js/modules/htmx.js',
},
output: {
path: path.resolve(__dirname, 'Swift','Files','Templates','Designs','Swift','Assets','js'),
filename: '[name].js'
},
module: {
rules: [
{
test: /\.js?$/,
loader: 'babel-loader'
}
]
},
optimization: {
minimize: isProduction,
minimizer: [
new TerserPlugin({
terserOptions: {
mangle: true,
format: {
comments: false,
}
},
})
]
}
},
{
name: 'styles',
mode: mode,
entry: {
'styles': './Swift/Files/Templates/Designs/Swift/Assets/_src/scss/swift.scss'
},
output: {
path: path.resolve(__dirname, 'Swift','Files','Templates','Designs','Swift','Assets','css'),
filename: '[name].js'
},
plugins: [
new StylelintPlugin({
configFile: '.stylelintrc.json',
files: 'Swift/Files/Templates/Designs/Swift/Assets/_src/scss/**/*.scss',
}),
new MiniCssExtractPlugin({
filename: '[name].css'
}),
new IgnoreEmitPlugin(/\.js$/),
],
module: {
rules: [
{
test: /.s?css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 1
}
},
'postcss-loader',
'sass-loader'
],
},
{
test: /\.(jpe?g|gif|png|svg)$/,
loader: 'url-loader',
}
]
},
optimization: {
minimize: isProduction,
minimizer: [
new OptimizeCssAssetsPlugin({
assetNameRegExp: /\.css$/,
cssProcessorOptions: {
map: {
inline: false,
annotation: true,
},
},
}),
]
}
}
]