assets-webpack-plugin
assets-webpack-plugin copied to clipboard
useCompilerPath option should respect webpack@5 defaults
Is your feature request related to a problem? Please describe.
Since webpack@5 recommends configuration cleanup and output.path
removing...
Consider removing defaults: Using output.path: path.resolve(__dirname, 'dist'): you can omit it, that's the default.
Describe the solution you'd like
...it would be great to properly handle this case (when useCompilerPath
option is enabled but no output.path
is provided).
Describe alternatives you've considered
Explicitly set output.path
is what I'm doing right now, but it feels redundant in webpack@5.
Additional context
Technically saying this is a bug, b/c, if path
is not set, webpack-assets.json
will be created in the project root ignoring useCompilerPath
setting, but I'd like to put it as a feature.
Repro:
const AssetsPlugin = require('assets-webpack-plugin');
const path = require('path');
module.exports = {
output: {
// path: path.resolve(__dirname, 'dist') // uncomment to fix
},
plugins: [
new AssetsPlugin({
useCompilerPath: true,
})
]
};
npm init -y
npm i webpack assets-webpack-plugin webpack-cli -D
npx webpack --mode production
Actual:
webpack-assets.json
created in project's root
Expected:
webpack-assets.json
created in dist
, since useCompilerPath
should respect webpack@5 defaults