Skip to content

Commit

Permalink
fix(loader): fix publicPath regression (#384)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmja authored and evilebottnawi committed May 14, 2019
1 parent f3a6dba commit 582ebfe
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function pitch(request) {
const childFilename = '*'; // eslint-disable-line no-path-concat
const publicPath =
typeof options.publicPath === 'string'
? options.publicPath.endsWith('/')
? options.publicPath === '' || options.publicPath.endsWith('/')
? options.publicPath
: `${options.publicPath}/`
: typeof options.publicPath === 'function'
Expand Down
2 changes: 2 additions & 0 deletions test/cases/publicpath-emptystring/expected/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
body { background: red; background-image: url(cd0bb358c45b584743d8ce4991777c42.svg); }

1 change: 1 addition & 0 deletions test/cases/publicpath-emptystring/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './style.css';
1 change: 1 addition & 0 deletions test/cases/publicpath-emptystring/react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions test/cases/publicpath-emptystring/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
body { background: red; background-image: url(./react.svg); }
37 changes: 37 additions & 0 deletions test/cases/publicpath-emptystring/webpack.config.js
Original file line number Diff line number Diff line change
@@ -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',
}),
],
};

0 comments on commit 582ebfe

Please sign in to comment.