Skip to content

Commit c278340

Browse files
committed
test: add test for inline css via query
1 parent 22a39db commit c278340

9 files changed

Lines changed: 94 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Home</title>
5+
<!-- inline CSS -->
6+
<style>.index-css-inline {
7+
color: red;
8+
}
9+
</style>
10+
<style>.style-css-inline {
11+
color: green;
12+
}
13+
</style>
14+
15+
<!-- resolve CSS file -->
16+
<link href="style-file.e2174e16.css" rel="stylesheet" />
17+
18+
<!-- inline JS -->
19+
<script>console.log(">> index.js");</script>
20+
</head>
21+
<body>
22+
<h1>Home</h1>
23+
<div class="index-css-inline">1</div>
24+
<div class="style-css-inline">2</div>
25+
<div class="style-css-file">3</div>
26+
</body>
27+
</html>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.style-css-file {
2+
color: blue;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.index-css-inline {
2+
color: red;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.style-css-file {
2+
color: blue;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.style-css-inline {
2+
color: green;
3+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Home</title>
5+
<!-- inline CSS -->
6+
<link href="./css/index.css?inline" rel="stylesheet" />
7+
<link href="./css/style.css?inline" rel="stylesheet" />
8+
9+
<!-- resolve CSS file -->
10+
<link href="./css/style-file.css" rel="stylesheet" />
11+
12+
<!-- inline JS -->
13+
<script src="./js/index.js?inline" defer="defer"></script>
14+
</head>
15+
<body>
16+
<h1>Home</h1>
17+
<div class="index-css-inline">1</div>
18+
<div class="style-css-inline">2</div>
19+
<div class="style-css-file">3</div>
20+
</body>
21+
</html>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('>> index.js');
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const path = require('path');
2+
const HtmlBundlerPlugin = require('@test/html-bundler-webpack-plugin');
3+
4+
module.exports = {
5+
mode: 'production',
6+
7+
output: {
8+
path: path.join(__dirname, 'dist/'),
9+
},
10+
11+
plugins: [
12+
new HtmlBundlerPlugin({
13+
entry: {
14+
index: './src/index.html',
15+
},
16+
css: {
17+
filename: '[name].[contenthash:8].css',
18+
},
19+
verbose: true,
20+
}),
21+
],
22+
23+
module: {
24+
rules: [
25+
{
26+
test: /\.(css)$/,
27+
use: ['css-loader'],
28+
},
29+
],
30+
},
31+
};

test/integration.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ describe('inline styles & scripts', () => {
248248
test('inline all assets into one HTML', () => compareFiles('inline-all-asset-to-html'));
249249

250250
test('inline CSS via `?inline` and resolve url()', () => compareFiles('inline-style-query'));
251+
test('inline many CSS via `?inline`', () => compareFiles('inline-style-query2'));
252+
251253
test('inline CSS, source map, via `?inline`', () => compareFiles('inline-style-query-with-source-map'));
252254
test('inline minimized CSS', () => compareFiles('inline-style-cssnano'));
253255
test('inline js via `?inline`', () => compareFiles('inline-script-query'));

0 commit comments

Comments
 (0)