-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.common.js
57 lines (54 loc) · 1.51 KB
/
webpack.config.common.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
import path, { dirname } from 'path';
import { unlink } from 'fs';
import { fileURLToPath } from 'url';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
import ESLintPlugin from 'eslint-webpack-plugin';
import StylelintPlugin from 'stylelint-webpack-plugin';
const JS_COMMON_CONFIG = {
entry: './entry/bundle.js',
output: {
path: path.resolve( fileURLToPath( dirname( import.meta.url ) ), 'build' ),
filename: 'accordion-slider.js'
},
plugins: [
new ESLintPlugin()
]
};
const CSS_COMMON_CONFIG = {
entry: './entry/style-bundle.js',
output: {
path: path.resolve( fileURLToPath( dirname( import.meta.url ) ), 'build' ),
filename: 'accordion-slider-css-build.js'
},
module: {
rules: [
{
test: /\.css$/i,
use: [ MiniCssExtractPlugin.loader, 'css-loader' ]
}
]
},
optimization: {
minimizer: [
new CssMinimizerPlugin()
]
},
plugins: [
new StylelintPlugin(),
new MiniCssExtractPlugin({
filename: 'accordion-slider.css'
}),
{
apply: ( compiler ) => {
compiler.hooks.done.tap( 'accordion-slider-js', async () => {
await unlink( 'build/accordion-slider-css-build.js', () => {} );
});
}
}
]
};
export {
JS_COMMON_CONFIG,
CSS_COMMON_CONFIG
};