caiobiodere / cordova-template-framework7-vue-webpack

Framework7 - Vue - Webpack Cordova Template with Webpack Dev Server and Hot Module Replacement
Apache License 2.0
621 stars 154 forks source link

Webpack release configuration doesn't work at all #156

Closed NikitaKA closed 5 years ago

NikitaKA commented 5 years ago

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.

caiobiodere commented 5 years ago

Please check the latest 2.3.9 version!