rebase and test

This commit is contained in:
ahabhgk 2024-03-15 21:01:12 +08:00
parent 4a360f63f5
commit 673278c692
33 changed files with 112 additions and 896 deletions

View File

@ -4184,7 +4184,7 @@ Object {
}
`;
exports[`ConfigCacheTestCases css urls-css-filename exported tests should be able to handle styles in div.css 1`] = `
exports[`ConfigCacheTestCases css urls exported tests should be able to handle styles in div.css 2`] = `
Object {
"--foo": " url(../../asset/img.09a1a1112c577c279435.png)",
"--foo-bar": " \\"http://www.example.com/pinkish.gif\\"",

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

View File

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

View File

@ -0,0 +1,7 @@
@import "./nested/index.css";
h1 {
same-dir: url('./img1.png');
nested-dir: url('./nested/img2.png');
nested-nested-dir: url('./nested/nested/img3.png');
}

View File

@ -1,18 +1,22 @@
const testCase = (tagName, impFn) => {
it(`should be able to handle styles in ${tagName}.css`, done => {
const element = document.createElement(tagName);
document.body.appendChild(element);
impFn().then(x => {
try {
expect(x).toEqual(nsObj({}));
const style = getComputedStyle(element);
expect(style).toMatchSnapshot();
done();
} catch (e) {
done(e);
}
}, done);
});
};
testCase("div", () => import("./spacing.css"));
it(`should generate correct url public path with css filename`, done => {
const h1 = document.createElement('h1');
document.body.appendChild(h1);
const h2 = document.createElement('h2');
document.body.appendChild(h1);
const h3 = document.createElement('h3');
document.body.appendChild(h1);
import("./index.css").then(x => {
try {
expect(x).toEqual(nsObj({}));
const style1 = getComputedStyle(h1);
expect(style1).toMatchSnapshot();
const style2 = getComputedStyle(h2);
expect(style2).toMatchSnapshot();
const style3 = getComputedStyle(h3);
expect(style3).toMatchSnapshot();
done();
} catch (e) {
done(e);
}
}, done);
});

View File

@ -1,5 +0,0 @@
@import url("#test");
.nested {
background: url('./img.png');
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

View File

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 76 KiB

View File

@ -0,0 +1,7 @@
@import "./nested/index.css";
h2 {
same-dir: url('./img2.png');
nested-dir: url('./nested/img3.png');
outer-dir: url('../img1.png');
}

View File

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 76 KiB

View File

@ -0,0 +1,5 @@
h3 {
same-dir: url('./img3.png');
outer-dir: url('../img2.png');
outer-outer-dir: url('../../img1.png');
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

View File

@ -1,4 +0,0 @@
{
"name": "package",
"version": "1.0.0"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

File diff suppressed because one or more lines are too long

View File

@ -1,16 +1,11 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
const common = {
target: "web",
mode: "development",
devtool: false,
experiments: {
css: true
},
output: {
cssFilename: "css/[name].css",
cssChunkFilename: "css/async/[name].css",
assetModuleFilename: "asset/[name].[hash][ext][query][fragment]"
},
optimization: {
splitChunks: {
cacheGroups: {
@ -30,3 +25,23 @@ module.exports = {
}
}
};
/** @type {import("../../../../").Configuration} */
module.exports = [
{
...common,
output: {
publicPath: "auto",
cssFilename: "bundle0/css/[name].css",
assetModuleFilename: "bundle0/asset/[name][ext]"
}
},
{
...common,
output: {
publicPath: "https://test.cases/path/",
cssFilename: "bundle1/css/[name].css",
assetModuleFilename: "bundle1/asset/[name][ext]"
}
}
];