extract-loader
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="3.1.0"></a> | ||
# [3.1.0](https://github.com/peerigon/extract-loader/compare/v3.0.0...v3.1.0) (2018-11-26) | ||
### Features | ||
* Accept function as publicPath option ([#51](https://github.com/peerigon/extract-loader/issues/51)) ([678933e](https://github.com/peerigon/extract-loader/commit/678933e)) | ||
<a name="3.0.0"></a> | ||
@@ -7,0 +17,0 @@ # [3.0.0](https://github.com/peerigon/extract-loader/compare/v2.0.1...v3.0.0) (2018-08-31) |
{ | ||
"name": "extract-loader", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "webpack loader to extract HTML and CSS from the bundle", | ||
@@ -5,0 +5,0 @@ "main": "lib/extractLoader.js", |
@@ -174,5 +174,5 @@ extract-loader | ||
There is currently exactly one option: `publicPath`. | ||
If you are using a relative `publicPath` in webpack's [output options](https://webpack.js.org/configuration/output/#output-publicpath) and extracting to a file with the `file-loader`, you might need this to account for the location of your extracted file. | ||
If you are using a relative `publicPath` in webpack's [output options](https://webpack.js.org/configuration/output/#output-publicpath) and extracting to a file with the `file-loader`, you might need this to account for the location of your extracted file. `publicPath` may be defined as a string or a function that accepts current [loader context](https://webpack.js.org/api/loaders/#the-loader-context) as single argument. | ||
Example: | ||
Example with publicPath option as a string: | ||
@@ -212,2 +212,38 @@ ```js | ||
Example with publicPath option as a function: | ||
```js | ||
module.exports = { | ||
output: { | ||
path: path.resolve("./dist"), | ||
publicPath: "dist/" | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/, | ||
use: [ | ||
{ | ||
loader: "file-loader", | ||
options: { | ||
name: "assets/[name].[ext]", | ||
}, | ||
}, | ||
{ | ||
loader: "extract-loader", | ||
options: { | ||
// dynamically return a relative publicPath based on how deep in directory structure the loaded file is in /src/ directory | ||
publicPath: (context) => '../'.repeat(path.relative(path.resolve('src'), context.context).split('/').length), | ||
} | ||
}, | ||
{ | ||
loader: "css-loader", | ||
}, | ||
], | ||
} | ||
] | ||
} | ||
}; | ||
``` | ||
You need another option? Then you should think about: | ||
@@ -214,0 +250,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
29659
272
0