Skip to content

Commit 90e0910

Browse files
committed
feat: support webpack4
1 parent c7181be commit 90e0910

File tree

6 files changed

+6011
-2484
lines changed

6 files changed

+6011
-2484
lines changed

.vscode/launch.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Launch Program",
11+
"program": "${workspaceFolder}\\test\\spec\\test.js",
12+
"args": [
13+
"--input-type=module"
14+
]
15+
}
16+
]
17+
}

example/basic/webpack.config.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
var ExtractTextPlugin = require('extract-text-webpack-plugin');
2-
var CSSSplitWebpackPlugin = require('../../').default;
1+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
2+
const CSSSplitWebpackPlugin = require('../../').default;
3+
4+
const miniCssConfig = {
5+
loader: MiniCssExtractPlugin.loader,
6+
options: {
7+
// you can specify a publicPath here
8+
// by default it uses publicPath in webpackOptions.output
9+
publicPath: '../',
10+
hmr: process.env.NODE_ENV === 'development',
11+
},
12+
};
313

414
module.exports = {
515
entry: './index.js',
@@ -10,19 +20,19 @@ module.exports = {
1020
filename: 'bundle.js',
1121
},
1222
module: {
13-
loaders: [{
23+
rules: [{
1424
test: /\.css$/,
15-
loader: ExtractTextPlugin.extract.length !== 1 ?
16-
ExtractTextPlugin.extract('style-loader', 'css-loader') :
17-
ExtractTextPlugin.extract({
18-
fallbackLoader: 'style-loader',
19-
loader: 'css-loader',
20-
}),
25+
use: [
26+
miniCssConfig,
27+
'css-loader',
28+
],
2129
}],
2230
},
2331
devtool: 'source-map',
2432
plugins: [
25-
new ExtractTextPlugin("styles.css"),
33+
new MiniCssExtractPlugin({
34+
filename: 'styles.css',
35+
}),
2636
new CSSSplitWebpackPlugin({size: 3, imports: true}),
2737
],
2838
};

example/less/webpack.config.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
var ExtractTextPlugin = require('extract-text-webpack-plugin');
2-
var CSSSplitWebpackPlugin = require('../../').default;
1+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
2+
const CSSSplitWebpackPlugin = require('../../').default;
3+
4+
const miniCssConfig = {
5+
loader: MiniCssExtractPlugin.loader,
6+
options: {
7+
// you can specify a publicPath here
8+
// by default it uses publicPath in webpackOptions.output
9+
publicPath: '../',
10+
hmr: process.env.NODE_ENV === 'development',
11+
},
12+
};
313

414
module.exports = {
515
entry: './index.js',
@@ -10,16 +20,20 @@ module.exports = {
1020
filename: 'bundle.js',
1121
},
1222
module: {
13-
loaders: [{
23+
rules: [{
1424
test: /\.less$/,
15-
loader: ExtractTextPlugin.extract(
16-
'css?-url&-autoprefixer&sourceMap!less?sourceMap'
17-
),
25+
use: [
26+
miniCssConfig,
27+
'css-loader',
28+
'less-loader',
29+
],
1830
}],
1931
},
2032
devtool: 'source-map',
2133
plugins: [
22-
new ExtractTextPlugin("styles.css"),
34+
new MiniCssExtractPlugin({
35+
filename: 'styles.css',
36+
}),
2337
new CSSSplitWebpackPlugin({size: 3}),
2438
],
2539
};

0 commit comments

Comments
 (0)