Do you want to request a feature or report a bug?
Bug
What is the current behaviour?
Recipe for disabling sourcemaps doesn't work. Code seems to run twice, and the second time it runs, the result of helpers.getPluginsByName(config, "UglifyJsPlugin")[0] is undefined.
The full recipe code.
export default (config, env, helpers) => {
let { plugin } = helpers.getPluginsByName(config, "UglifyJsPlugin")[0];
plugin.options.sourceMap = false
}
My exact config. Note this is a custom config file - preact.config.prod.js
const webpack = require('webpack')
module.exports = function(config, env, helpers) {
config.plugins.push(
new webpack.DefinePlugin({
SLS_ENDPOINT_BASE: JSON.stringify('unrelated')
})
)
/* This runs twice, and the second time, uglify is undefined */
const uglify = helpers.getPluginsByName(config, 'UglifyJsPlugin')[0]
console.log(JSON.stringify(uglify))
console.log(typeof uglify)
uglify.plugin.options.sourceMap = false
}
I get the same result if I comment out the config.plugins.push part, and also if I change to export default.
If the current behaviour is a bug, please provide the steps to reproduce.
preact build --config my.preact.config.jsWhat is the expected behaviour?
No errors, turn off source maps in build.
If this is a feature request, what is motivation or use case for changing the behaviour?
Please mention other relevant information.
You have to disable it via webpack config actually. I'll follow up with a snippet after dinner
So, at least in my case, I want to disable sourcemaps for production:
// preact.config.js
module.exports = function (config, env) {
if (env.isProd) {
config.devtool = false; // disable sourcemaps
}
}
You can go thru the trouble of disabling sourcemaps individually for each plugin -- I have tried, it doesn't work. This is because webpack still is the ultimate decider in whether or not maps should be emitted.
That said, this disables _all_ mappings.
Thanks, this works for my use case :) Should I close the issue or do you want to leave it open until the recipe is updated?
Great! Let's go ahead & close it 馃槃There are a lot of changes in the works, and we'll touch on the recipes area too
Thanks!
Most helpful comment
So, at least in my case, I want to disable sourcemaps for production:
You can go thru the trouble of disabling sourcemaps individually for each plugin -- I have tried, it doesn't work. This is because webpack still is the ultimate decider in whether or not maps should be emitted.
That said, this disables _all_ mappings.