Skip to content

Commit 3869ee8

Browse files
committed
feat: ability to disable extract async modules, add manual test
1 parent 2b9f3d8 commit 3869ee8

File tree

5 files changed

+14
-1
lines changed

5 files changed

+14
-1
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"npm-run-all": "^4.1.5",
7373
"prettier": "^1.18.2",
7474
"standard-version": "^6.0.1",
75+
"style-loader": "^0.23.1",
7576
"webpack": "^4.35.3",
7677
"webpack-cli": "^3.3.6",
7778
"webpack-dev-server": "^3.7.2"

test/manual/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<p>Lazy CSS: Must be red, but turn green when <button class="lazy-button">pressing this button</button>.</p>
3434
<p>But turn orange, when <button class="lazy-button2">pressing this button</button>. Additional clicks have no effect.</p>
3535
<p>Refresh and press buttons in reverse order: This should turn green instead.</p>
36+
<p class="async-disabled">This should turn yellow after pressing "lazy-button" without loading extra css file containing "async-disabled.css".</p>
3637
</div>
3738
<div class="test lazy-failure-css">
3839
<p>Lazy CSS: Turn off the network and <button class="lazy-failure-button">press this button</button>.</p>

test/manual/src/async-disabled.css

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.async-disabled {
2+
background: yellow;
3+
}

test/manual/src/lazy.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/* eslint-env browser */
22

33
import './lazy.css';
4+
import './async-disabled.css';

test/manual/webpack.config.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,21 @@ module.exports = {
1111
rules: [
1212
{
1313
test: /\.css$/,
14-
use: [Self.loader, 'css-loader'],
14+
use: ['style-loader', Self.loader, 'css-loader'],
1515
},
1616
],
1717
},
1818
plugins: [
1919
new Self({
2020
filename: '[name].css',
2121
chunkFilename: '[contenthash].css',
22+
disableAsync({ module }) {
23+
let ret = false;
24+
if (module.content.indexOf('async-disabled') > -1) {
25+
ret = true;
26+
}
27+
return ret;
28+
},
2229
}),
2330
],
2431
devServer: {

0 commit comments

Comments
 (0)