-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
100 lines (97 loc) · 4.04 KB
/
webpack.config.js
File metadata and controls
100 lines (97 loc) · 4.04 KB
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
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const autoprefixer = require('autoprefixer');
const RtlCssPlugin = require('rtlcss-webpack-plugin');
module.exports = (env, argv) => {
const isDevelopment = argv.mode === 'development';
return {
entry: {
'css-max/atomic-max': './scss/grid-max.scss',
'css/atomic': './scss/grid.scss',
'demo/colormode-globalstyle/dynamic': './demo/colormode-globalstyle/scss/dynamic.scss',
'demo/colormode-globalstyle/colormode-globalstyle': './demo/colormode-globalstyle/colormode-globalstyle.scss',
},
output: {
path: path.resolve(__dirname), // Outputs to the current directory
},
module: {
rules: [
{
test: /\.scss$/, // Match all SCSS files
use: [
MiniCssExtractPlugin.loader, // Extract CSS to files
'css-loader', // Translate CSS into CommonJS modules
{
loader: 'postcss-loader', // Apply PostCSS transformations
options: {
postcssOptions: {
plugins: [
autoprefixer({
overrideBrowserslist: ['last 5 versions'], // Autoprefix for browsers
}),
],
},
},
},
'sass-loader', // Compile Sass to CSS (must run before PostCSS)
],
},
],
},
plugins: [
// Output for non-minified CSS
new MiniCssExtractPlugin({
filename: (pathData) => {
const name = pathData.chunk.name; // Get the entry name
return `${name}.css`; // Non-minified CSS
},
}),
// Output for RTL non-minified CSS
new RtlCssPlugin({
filename: (pathData) => {
const name = pathData.chunk.name; // Get the entry name
return `${name}-rtl.css`; // Non-minified RTL CSS
},
}),
// Output for minified CSS
new MiniCssExtractPlugin({
filename: (pathData) => {
const name = pathData.chunk.name; // Get the entry name
return `${name}.min.css`; // Minified CSS
},
}),
// Output for minified RTL CSS
new RtlCssPlugin({
filename: (pathData) => {
const name = pathData.chunk.name; // Get the entry name
return `${name}.min-rtl.css`; // Minified RTL CSS
},
}),
],
optimization: {
minimize: true, // Enable minimization
minimizer: [
new CssMinimizerPlugin({
test: /\.min(-rtl)?\.css$/i, // Match both .min.css and .min-rtl.css files
minimizerOptions: {
preset: [
'default',
{
discardComments: { removeAll: true }, // Remove comments in production
},
],
},
}),
],
},
devtool: isDevelopment ? 'source-map' : false, // Enable source maps for development mode
watchOptions: {
ignored: /node_modules/, // Ignore node_modules to speed up watching
},
// Avoid outputting any actual JS files (use an empty JS entry as a workaround)
performance: {
hints: false, // Disable performance hints (since no actual JS is needed)
},
};
};