-
-
Notifications
You must be signed in to change notification settings - Fork 568
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: lightningcss-loader targets array not work as expected (#7331)
* fix: lightningcss-loader targets array not work as expected * docs: fix * test: fix * fix: folder name
- Loading branch information
1 parent
6fb4b36
commit c507fe6
Showing
10 changed files
with
200 additions
and
30 deletions.
There are no files selected for viewing
3 changes: 0 additions & 3 deletions
3
...k-test-tools/tests/configCases/builtin-lightningcss-loader/basic-include/rspack.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
5 changes: 5 additions & 0 deletions
5
...tools/tests/configCases/builtin-lightningcss-loader/prefixes-with-targets-array/index.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,5 @@ | ||
.foo { | ||
transition: all .5s; | ||
user-select: none; | ||
background: linear-gradient(to bottom, white, black); | ||
} |
19 changes: 19 additions & 0 deletions
19
...-tools/tests/configCases/builtin-lightningcss-loader/prefixes-with-targets-array/index.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,19 @@ | ||
import './index.css' | ||
|
||
const fs = require("node:fs"); | ||
const path = require("node:path"); | ||
|
||
it("should transform CSS and add prefixes correctly", () => { | ||
const css = fs.readFileSync( | ||
path.resolve(__dirname, "./bundle0.css"), | ||
"utf-8" | ||
); | ||
|
||
expect(css.includes('-webkit-user-select: none;')).toBeTruthy(); | ||
expect(css.includes('-ms-user-select: none;')).toBeTruthy(); | ||
expect(css.includes('user-select: none;')).toBeTruthy(); | ||
expect(css.includes('background: -webkit-linear-gradient(#fff, #000);')).toBeTruthy(); | ||
expect(css.includes('background: linear-gradient(#fff, #000);')).toBeTruthy(); | ||
expect(css.includes('-webkit-transition: all .5s;')).toBeTruthy(); | ||
expect(css.includes('transition: all .5s;')).toBeTruthy(); | ||
}); |
32 changes: 32 additions & 0 deletions
32
...ests/configCases/builtin-lightningcss-loader/prefixes-with-targets-array/rspack.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,32 @@ | ||
/** @type {import("@rspack/core").Configuration} */ | ||
module.exports = { | ||
module: { | ||
generator: { | ||
"css/auto": { | ||
exportsOnly: false, | ||
} | ||
}, | ||
rules: [ | ||
{ | ||
test: /\.css$/, | ||
use: [ | ||
{ | ||
loader: "builtin:lightningcss-loader", | ||
/** @type {import("@rspack/core").LightningcssLoaderOptions} */ | ||
options: { | ||
targets: [ | ||
'Edge >= 12', | ||
'iOS >= 8', | ||
'Android >= 4.0' | ||
] | ||
} | ||
} | ||
], | ||
type: "css/auto" | ||
} | ||
] | ||
}, | ||
experiments: { | ||
css: true | ||
} | ||
}; |
3 changes: 3 additions & 0 deletions
3
...ools/tests/configCases/builtin-lightningcss-loader/prefixes-with-targets-string/index.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 @@ | ||
.foo { | ||
user-select: none; | ||
} |
14 changes: 14 additions & 0 deletions
14
...tools/tests/configCases/builtin-lightningcss-loader/prefixes-with-targets-string/index.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,14 @@ | ||
import './index.css' | ||
|
||
const fs = require("node:fs"); | ||
const path = require("node:path"); | ||
|
||
it("should transform CSS and add prefixes correctly", () => { | ||
const css = fs.readFileSync( | ||
path.resolve(__dirname, "./bundle0.css"), | ||
"utf-8" | ||
); | ||
|
||
expect(css.includes('-ms-user-select: none;')).toBeTruthy(); | ||
expect(css.includes('user-select: none;')).toBeTruthy(); | ||
}); |
30 changes: 30 additions & 0 deletions
30
...sts/configCases/builtin-lightningcss-loader/prefixes-with-targets-string/rspack.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,30 @@ | ||
/** @type {import("@rspack/core").Configuration} */ | ||
module.exports = { | ||
module: { | ||
generator: { | ||
"css/auto": { | ||
exportsOnly: false, | ||
} | ||
}, | ||
rules: [ | ||
{ | ||
test: /\.css$/, | ||
use: [ | ||
{ | ||
loader: "builtin:lightningcss-loader", | ||
/** @type {import("@rspack/core").LightningcssLoaderOptions} */ | ||
options: { | ||
targets: [ | ||
'Edge >= 12' | ||
] | ||
} | ||
} | ||
], | ||
type: "css/auto" | ||
} | ||
] | ||
}, | ||
experiments: { | ||
css: true | ||
} | ||
}; |
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
c507fe6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Ran ecosystem CI: Open
c507fe6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Benchmark detail: Open