-
-
Notifications
You must be signed in to change notification settings - Fork 387
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
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,9 @@ import NodeTargetPlugin from 'webpack/lib/node/NodeTargetPlugin'; | |
import LibraryTemplatePlugin from 'webpack/lib/LibraryTemplatePlugin'; | ||
import SingleEntryPlugin from 'webpack/lib/SingleEntryPlugin'; | ||
import LimitChunkCountPlugin from 'webpack/lib/optimize/LimitChunkCountPlugin'; | ||
import validateOptions from 'schema-utils'; | ||
|
||
import schema from './options.json'; | ||
|
||
const MODULE_TYPE = 'css/mini-extract'; | ||
const pluginName = 'mini-css-extract-plugin'; | ||
|
@@ -29,12 +32,17 @@ const findModuleById = (modules, id) => { | |
|
||
export function pitch(request) { | ||
const query = loaderUtils.getOptions(this) || {}; | ||
|
||
validateOptions(schema, query, 'Mini CSS Extract Plugin Loader'); | ||
|
||
const loaders = this.loaders.slice(this.loaderIndex + 1); | ||
this.addDependency(this.resourcePath); | ||
const childFilename = '*'; // eslint-disable-line no-path-concat | ||
const publicPath = | ||
typeof query.publicPath === 'string' | ||
? query.publicPath | ||
: typeof query.publicPath === 'function' | ||
? query.publicPath(this.resourcePath, this.rootContext) | ||
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 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 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. 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? 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; | ||
const outputOptions = { | ||
filename: childFilename, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"additionalProperties": true, | ||
"properties": { | ||
"publicPath": { | ||
"anyOf": [ | ||
{ | ||
"type": "string" | ||
}, | ||
{ | ||
"instanceof": "Function" | ||
} | ||
] | ||
} | ||
}, | ||
"errorMessages": { | ||
"publicPath": "should be {String} or {Function} (https://github.com/webpack-contrib/mini-css-extract-plugin#publicpath)" | ||
}, | ||
"type": "object" | ||
} |
Uh oh!
There was an error while loading. Please reload this page.