When building to production, wrong configuration is used!
After few months of development I've tried to build my app to production and was confused: cordova build android --release use webpack.dev configuration. You can easily check this out by inserting console.log into ifs inside webpack.config.js. In current version of this repo webpack.release.js throws error: path is not defined. The third problem is when you fix previous issues: bundle doesn't contain cordova.
I have tried to fix that by adding CordovaHtmlOutputPlugin into release configuration but that didn't help. UPDATE works!
{
mode: 'production',
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new CleanPlugin('www', {
root: path.join(__dirname, '.'),
dry: false,
verbose: false,
exclude: ['index.html']
}),
new CordovaHtmlOutputPlugin()
],
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: false
}),
new OptimizeCSSAssetsPlugin({})
]
}
}
UPDATE
I have tested that with my own webpack configuration (slightly modified, but I didn't touch anything related to cordova, only separated config and added minor changes). In current version of this repo running webpack.release.js ends up with errors.
When building to production, wrong configuration is used!
After few months of development I've tried to build my app to production and was confused:
cordova build android --release
use webpack.dev configuration. You can easily check this out by insertingconsole.log
into ifs insidewebpack.config.js
. In current version of this repowebpack.release.js
throws error:path is not defined
. The third problem is when you fix previous issues: bundle doesn't contain cordova.I have tried to fix that by adding
CordovaHtmlOutputPlugin
into release configurationbut that didn't help. UPDATE works!UPDATE I have tested that with my own webpack configuration (slightly modified, but I didn't touch anything related to cordova, only separated config and added minor changes). In current version of this repo running
webpack.release.js
ends up with errors.