webpack.js.org
webpack.js.org copied to clipboard
Webpack only emits file in development mode
Bug report
What is the current behavior?
Webpack only emits file in development mode.
If the current behavior is a bug, please provide the steps to reproduce.
const compiler_main = webpack({
...main,
mode: "production",
devtool: "inline-nosources-cheap-module-source-map",
}, () => {
const compiler_preload = webpack({
...preload,
mode: "production",
devtool: "inline-nosources-cheap-module-source-map",
}, () => {
const compiler_renderer = webpack({
...renderer,
mode: "production",
devtool: "inline-nosources-cheap-module-source-map",
}, () => {
// rest code goes here
});
});
});
What is the expected behavior?
Webpack emits file regardless of current mode.
Other relevant information: webpack version: 5.47.1 Node.js version: node-v16.6.0-x64 Operating System: Windows 10 Pro Additional tools:
For maintainers only:
- [ ] webpack-4
- [ ] webpack-5
- [ ] bug
- [ ] critical-bug
- [ ] enhancement
- [ ] documentation
- [ ] performance
- [ ] dependencies
- [ ] question
You should run ‘close’ after compilation, please look at docs https://webpack.js.org/api/node/#run
Cc @chenxsan i think we should update all examples with close
You should run ‘close’ after compilation, please look at docs https://webpack.js.org/api/node/#run
tried but still the same. I got working workaround though
mode: "development",
devtool: "inline-nosources-cheap-module-source-map",
plugins: [
new webpack.DefinePlugin({
"process.env": {
"NODE_ENV": JSON.stringify("production")
}
})
]
Cc @chenxsan i think we should update all examples with close
Per https://webpack.js.org/blog/2020-10-10-webpack-5-release/#compiler-idle-and-close:
The
webpack()façade automatically callsclosewhen being passed a callback.
So in this specific issue, there seems no need to close compilers.
But there's indeed one example needs an update with the close method.
@Sombian Maybe you could create a reproducible repository so we can investigate?
@Sombian Maybe you could create a reproducible repository so we can investigate?
Repo: https://github.com/Any-Material/nozomi-material
So, it seems, mode must be set to development, but since I want to optimize / minimize code for production,
development output isnt quite appealing to me, then again, production won't emit files what so ever.
plugins: [
new webpack.DefinePlugin({
"process.env": {
"NODE_ENV": JSON.stringify("production")
}
})
]
Thats why I added this section of code.
Quick thing to note is, setting proccess.env.NODE_ENV directly doesn't do anything.