Skip to content

Commit

Permalink
test(option): added testing of disableAsync option
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasbaldwin committed Jul 31, 2019
1 parent e6358e1 commit 45e22e8
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"test:watch": "cross-env NODE_ENV=test jest --watch",
"test:coverage": "cross-env NODE_ENV=test jest --collectCoverageFrom=\"src/**/*.js\" --coverage",
"test:manual": "webpack-dev-server test/manual/src/index.js --open --config test/manual/webpack.config.js",
"test:manualDisableAsync": "webpack-dev-server test/manualDisableAsyncOption/src/index.js --open --config test/manualDisableAsyncOption/webpack.config.js",
"pretest": "npm run lint",
"test": "cross-env NODE_ENV=test npm run test:coverage",
"defaults": "webpack-defaults"
Expand Down
15 changes: 15 additions & 0 deletions test/manualDisableAsyncOption/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>mini-css-extract-plugin testcase</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="/dist/a.css" />
</head>
<body>
<script type="text/javascript" src="/dist/a.js"></script>
<script type="text/javascript" src="/dist/b.js"></script>
<script type="text/javascript" src="/dist/main.js"></script>
</body>
</html>
7 changes: 7 additions & 0 deletions test/manualDisableAsyncOption/src/a.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.container {
background: blue;
color: red;
width: 100%;
height: 20px;
text-align: center;
}
7 changes: 7 additions & 0 deletions test/manualDisableAsyncOption/src/b.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.container {
background: purple;
color: green;
width: 100%;
height: 20px;
text-align: center;
}
14 changes: 14 additions & 0 deletions test/manualDisableAsyncOption/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* eslint-env browser */

import './a.css';
import './b.css';

const render = () => {
const div = document.createElement('div');
div.setAttribute('class', 'container');
const text = 'My background color should be blue, and my text should be red!';
div.innerHTML = text;
document.body.appendChild(div);
};

render();
45 changes: 45 additions & 0 deletions test/manualDisableAsyncOption/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const Self = require('../../');

module.exports = {
mode: 'development',
output: {
chunkFilename: '[name].js',
publicPath: '/dist/',
crossOriginLoading: 'anonymous',
},
optimization: {
splitChunks: {
cacheGroups: {
default: false,
a: {
name: 'a',
test: /a.css/,
chunks: 'all',
enforce: true,
},
b: {
name: 'b',
test: /b.css/,
chunks: 'all',
enforce: true,
},
},
},
},
module: {
rules: [
{
test: /\.css$/,
use: [Self.loader, 'css-loader'],
},
],
},
plugins: [
new Self({
filename: '[name].css',
}),
],
devServer: {
contentBase: __dirname,
},
};

0 comments on commit 45e22e8

Please sign in to comment.