Skip to content

Commit fab158d

Browse files
committed
fix: lack of trailing slash on publicPath string option
1 parent 5db65d2 commit fab158d

File tree

6 files changed

+42
-1
lines changed

6 files changed

+42
-1
lines changed

src/loader.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ export function pitch(request) {
4040
const childFilename = '*'; // eslint-disable-line no-path-concat
4141
const publicPath =
4242
typeof query.publicPath === 'string'
43-
? query.publicPath
43+
? query.publicPath.endsWith('/')
44+
? query.publicPath
45+
: `${query.publicPath}/`
4446
: typeof query.publicPath === 'function'
4547
? query.publicPath(this.resourcePath, this.rootContext)
4648
: this._compilation.outputOptions.publicPath;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
body { background: red; background-image: url(/static/img/cd0bb358c45b584743d8ce4991777c42.svg); }
2+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './style.css';
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
body { background: red; background-image: url(./react.svg); }
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const Self = require('../../../');
2+
3+
module.exports = {
4+
entry: './index.js',
5+
module: {
6+
rules: [
7+
{
8+
test: /\.css$/,
9+
use: [
10+
{
11+
loader: Self.loader,
12+
options: {
13+
publicPath: '/static/img'
14+
}
15+
},
16+
'css-loader',
17+
],
18+
}, {
19+
test: /\.(svg|png)$/,
20+
use: [{
21+
loader: 'file-loader',
22+
options: {
23+
filename: '[name].[ext]'
24+
}
25+
}]
26+
}
27+
],
28+
},
29+
plugins: [
30+
new Self({
31+
filename: '[name].css',
32+
}),
33+
],
34+
};

0 commit comments

Comments
 (0)