From 85643bb865c238708d4b585673f8b0a31ee44c5f Mon Sep 17 00:00:00 2001 From: Rasmus Melchior Jacobsen Date: Fri, 26 Apr 2019 20:51:17 +0200 Subject: [PATCH] test(loader): Add test for the case when publicPath is an empty string --- .../publicpath-emptystring/expected/main.css | 2 + test/cases/publicpath-emptystring/index.js | 1 + test/cases/publicpath-emptystring/react.svg | 1 + test/cases/publicpath-emptystring/style.css | 1 + .../publicpath-emptystring/webpack.config.js | 37 +++++++++++++++++++ 5 files changed, 42 insertions(+) create mode 100644 test/cases/publicpath-emptystring/expected/main.css create mode 100644 test/cases/publicpath-emptystring/index.js create mode 100644 test/cases/publicpath-emptystring/react.svg create mode 100644 test/cases/publicpath-emptystring/style.css create mode 100644 test/cases/publicpath-emptystring/webpack.config.js diff --git a/test/cases/publicpath-emptystring/expected/main.css b/test/cases/publicpath-emptystring/expected/main.css new file mode 100644 index 00000000..f6674281 --- /dev/null +++ b/test/cases/publicpath-emptystring/expected/main.css @@ -0,0 +1,2 @@ +body { background: red; background-image: url(cd0bb358c45b584743d8ce4991777c42.svg); } + diff --git a/test/cases/publicpath-emptystring/index.js b/test/cases/publicpath-emptystring/index.js new file mode 100644 index 00000000..aa3357bf --- /dev/null +++ b/test/cases/publicpath-emptystring/index.js @@ -0,0 +1 @@ +import './style.css'; diff --git a/test/cases/publicpath-emptystring/react.svg b/test/cases/publicpath-emptystring/react.svg new file mode 100644 index 00000000..5b3b22a4 --- /dev/null +++ b/test/cases/publicpath-emptystring/react.svg @@ -0,0 +1 @@ +logo-on-dark-bg \ No newline at end of file diff --git a/test/cases/publicpath-emptystring/style.css b/test/cases/publicpath-emptystring/style.css new file mode 100644 index 00000000..edcbc24a --- /dev/null +++ b/test/cases/publicpath-emptystring/style.css @@ -0,0 +1 @@ +body { background: red; background-image: url(./react.svg); } diff --git a/test/cases/publicpath-emptystring/webpack.config.js b/test/cases/publicpath-emptystring/webpack.config.js new file mode 100644 index 00000000..eb6125c8 --- /dev/null +++ b/test/cases/publicpath-emptystring/webpack.config.js @@ -0,0 +1,37 @@ +import Self from '../../../src'; + +module.exports = { + entry: './index.js', + module: { + rules: [ + { + test: /\.css$/, + use: [ + { + loader: Self.loader, + options: { + publicPath: '', + }, + }, + 'css-loader', + ], + }, + { + test: /\.(svg|png)$/, + use: [ + { + loader: 'file-loader', + options: { + filename: '[name].[ext]', + }, + }, + ], + }, + ], + }, + plugins: [ + new Self({ + filename: '[name].css', + }), + ], +};