-
-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: error when using function in webpack output.publicPath
- Loading branch information
1 parent
e8c08a1
commit c568970
Showing
3 changed files
with
65 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`public path should work with function output.publicPath: DOM 1`] = ` | ||
"<!DOCTYPE html><html><head> | ||
<title>style-loader test</title> | ||
<style id=\\"existing-style\\">.existing { color: yellow }</style> | ||
</head> | ||
<body> | ||
<h1>Body</h1> | ||
<div class=\\"target\\"></div> | ||
<iframe class=\\"iframeTarget\\"></iframe> | ||
</body></html>" | ||
`; | ||
exports[`public path should work with function output.publicPath: errors 1`] = `Array []`; | ||
exports[`public path should work with function output.publicPath: warnings 1`] = `Array []`; |
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,41 @@ | ||
/* eslint-env browser */ | ||
import path from "path"; | ||
|
||
import MiniCssExtractPlugin from "../src/cjs"; | ||
|
||
import { | ||
compile, | ||
getCompiler, | ||
getErrors, | ||
getWarnings, | ||
runInJsDom, | ||
} from "./helpers/index"; | ||
|
||
describe("public path", () => { | ||
it("should work with function output.publicPath", async () => { | ||
const compiler = getCompiler( | ||
"simple.js", | ||
{}, | ||
{ | ||
output: { | ||
publicPath() { return "" }, | ||
path: path.resolve(__dirname, "../outputs"), | ||
filename: "[name].bundle.js", | ||
}, | ||
plugins: [ | ||
new MiniCssExtractPlugin({ | ||
filename: "[name].css", | ||
}), | ||
], | ||
} | ||
); | ||
const stats = await compile(compiler); | ||
|
||
runInJsDom("main.bundle.js", compiler, stats, (dom, bundle) => { | ||
expect(dom.serialize()).toMatchSnapshot("DOM"); | ||
}); | ||
|
||
expect(getWarnings(stats)).toMatchSnapshot("warnings"); | ||
expect(getErrors(stats)).toMatchSnapshot("errors"); | ||
}); | ||
}); |