-
-
Notifications
You must be signed in to change notification settings - Fork 392
publicPath can now be a function #373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
098a268
5db65d2
fab158d
a9985d8
0f76012
9ef1de0
1b691ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,7 +40,9 @@ export function pitch(request) { | |
| const childFilename = '*'; // eslint-disable-line no-path-concat | ||
| const publicPath = | ||
| typeof query.publicPath === 'string' | ||
| ? query.publicPath | ||
| ? query.publicPath.endsWith('/') | ||
| ? query.publicPath | ||
| : `${query.publicPath}/` | ||
| : typeof query.publicPath === 'function' | ||
| ? query.publicPath(this.resourcePath, this.rootContext) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need here
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @evilebottnawi in
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @karlvr @evilebottnawi Just wanted to let you know that this introduces a breaking change in the case when the publicPath is set to an empty string meaning that resources are located in the same directory as the css file, e.g.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That change was to follow the same behaviour in https://github.com/webpack-contrib/file-loader/blob/master/src/index.js#L37 I'm really sorry about this regression! @evilebottnawi shall we introduce a special case for an empty string here?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| : this._compilation.outputOptions.publicPath; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| body { background: red; background-image: url(/static/img/cd0bb358c45b584743d8ce4991777c42.svg); } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| import './style.css'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| body { background: red; background-image: url(./react.svg); } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| const Self = require('../../../'); | ||
|
|
||
| module.exports = { | ||
| entry: './index.js', | ||
| module: { | ||
| rules: [ | ||
| { | ||
| test: /\.css$/, | ||
| use: [ | ||
| { | ||
| loader: Self.loader, | ||
| options: { | ||
| publicPath: '/static/img' | ||
| } | ||
| }, | ||
| 'css-loader', | ||
| ], | ||
| }, { | ||
| test: /\.(svg|png)$/, | ||
| use: [{ | ||
| loader: 'file-loader', | ||
| options: { | ||
| filename: '[name].[ext]' | ||
| } | ||
| }] | ||
| } | ||
| ], | ||
| }, | ||
| plugins: [ | ||
| new Self({ | ||
| filename: '[name].css', | ||
| }), | ||
| ], | ||
| }; |
Uh oh!
There was an error while loading. Please reload this page.