-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Burhanuddin Udaipurwala
committed
Jun 3, 2023
1 parent
550df9d
commit d3ad1ac
Showing
2 changed files
with
29 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
import * as style from "./style.css"; | ||
import "./style.css"; | ||
|
||
it("should compile and load style on demand", done => { | ||
expect(style).toEqual(nsObj({})); | ||
it("should compile", done => { | ||
import("./style.css").then(x => { | ||
expect(x).toEqual(nsObj({})); | ||
const style = getComputedStyle(document.body); | ||
expect(style.getPropertyValue("background")).toBe(" red"); | ||
expect(style.getPropertyValue("background")).toBe("red"); | ||
done(); | ||
}, done); | ||
}); |
28 changes: 26 additions & 2 deletions
28
test/configCases/optimization/css-minimize/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 |
---|---|---|
@@ -1,11 +1,35 @@ | ||
const Compilation = require("../../../../").Compilation; | ||
const Source = require("webpack-sources").Source; | ||
|
||
/** @type {import("../../../../").Configuration} */ | ||
module.exports = { | ||
target: "web", | ||
mode: "production", | ||
experiments: { | ||
css: true | ||
}, | ||
optimization: { | ||
minimize: true | ||
} | ||
}, | ||
plugins: [ | ||
compiler => { | ||
const files = {}; | ||
compiler.hooks.assetEmitted.tap( | ||
"Test", | ||
(file, { content, source, outputPath, compilation, targetPath }) => { | ||
expect(Buffer.isBuffer(content)).toBe(true); | ||
expect(source).toBeInstanceOf(Source); | ||
expect(typeof outputPath).toBe("string"); | ||
expect(typeof targetPath).toBe("string"); | ||
expect(compilation).toBeInstanceOf(Compilation); | ||
files[file] = content.toString("utf-8"); | ||
} | ||
); | ||
compiler.hooks.afterEmit.tap("Test", () => { | ||
// css should be minimized | ||
expect(files["bundle0.css"]).toMatchInlineSnapshot( | ||
`"body{background:red}head{--webpack-179:_258}"` | ||
); | ||
}); | ||
} | ||
] | ||
}; |