-
-
Notifications
You must be signed in to change notification settings - Fork 562
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: css loading initial chunks (#4136)
- Loading branch information
Showing
14 changed files
with
96 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/rspack/tests/runtimeCases/runtime/split-css-chunk-async/common.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#dynamic { | ||
background: red; | ||
} |
1 change: 1 addition & 0 deletions
1
packages/rspack/tests/runtimeCases/runtime/split-css-chunk-async/common.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "./common.css"; |
10 changes: 10 additions & 0 deletions
10
packages/rspack/tests/runtimeCases/runtime/split-css-chunk-async/index1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
it("should load css chunk", function (done) { | ||
import("./share").then(module => { | ||
expect(module.value).toBe(1); | ||
// test is only for css loading | ||
if (__webpack_require__.f.css) { | ||
expect(document.getElementsByTagName("link").length).toBe(2); | ||
} | ||
done(); | ||
}); | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/rspack/tests/runtimeCases/runtime/split-css-chunk-async/index2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "./common"; |
1 change: 1 addition & 0 deletions
1
packages/rspack/tests/runtimeCases/runtime/split-css-chunk-async/index3.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "./share"; |
File renamed without changes.
4 changes: 4 additions & 0 deletions
4
packages/rspack/tests/runtimeCases/runtime/split-css-chunk-async/share.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import "./share.css"; | ||
import "./common.css"; | ||
|
||
export const value = 1; |
29 changes: 29 additions & 0 deletions
29
packages/rspack/tests/runtimeCases/runtime/split-css-chunk-async/webpack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module.exports = { | ||
entry: { | ||
main: './index1.js', | ||
main2: './index2.js', | ||
main3: './index3.js' | ||
}, | ||
output: { | ||
chunkFilename: '[id].[contenthash].js' | ||
}, | ||
optimization: { | ||
splitChunks: { | ||
cacheGroups: { | ||
common: { | ||
chunks: 'all', | ||
test: /common/, | ||
enforce: true, | ||
name: 'common' | ||
}, | ||
share: { | ||
chunks: 'all', | ||
test: /share/, | ||
enforce: true, | ||
name: 'share' | ||
} | ||
} | ||
}, | ||
runtimeChunk: 'single' | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/rspack/tests/runtimeCases/runtime/split-css-chunk/common.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
import "./common.css"; | ||
|
||
export const value = 1; |
5 changes: 1 addition & 4 deletions
5
packages/rspack/tests/runtimeCases/runtime/split-css-chunk/index1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
it("should load css chunk", function (done) { | ||
import("./common").then(module => { | ||
expect(module.value).toBe(1); | ||
// test is only for css loading | ||
if (__webpack_require__.f.css) { | ||
expect(document.getElementsByTagName("link").length).toBe(1); | ||
} | ||
done(); | ||
}); | ||
}); | ||
|
||
import "./common.css"; | ||
|
||
// ./common.css is initial chunks and also be async chunks. |
2 changes: 0 additions & 2 deletions
2
packages/rspack/tests/runtimeCases/runtime/split-css-chunk/index2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
import "./common"; | ||
|
||
import("./other.css"); |