reactjs - Webpack : split and share vendor chunk across pages not working -


i configured webpack split vendor , app chunk. vendor chunk used across page. vendor file work app file built it. project has multiple page, each page built on own , have own app.js , bse.js. want use bse.js across pages.

page have:  - app.js  - bse.js page b have:  - app.js  - bse.js page c have:  - app.js  - bse.js 

i want use bse.js shared vendor chunk pages. browsers load file 1 time.

here configuration file each page.

module.exports = function (grunt) {  var webpack = require('webpack'); var path = require('path');   var entry = {     app:path.join(__dirname, './jvs/app.js') ,     bse:['react', 'react-dom']  //vendor bundle };  var commonplugin = [new webpack.optimize.commonschunkplugin({     name: "bse",     filename:"bse.js",     minchunks: infinity })]; var commonpluginproduction = [new webpack.optimize.commonschunkplugin({     name: "bse",     filename:"bse.js",     minchunks: infinity })];  // need uglify code on deploy var uglifyplugin = [         new webpack.optimize.uglifyjsplugin(             {                 compress: {                     drop_console: true                 },                 output: {                     comments: false                 }             }         ),     ];   // loader transforms our jsx content var module = {     loaders: [         {             test: /.js?$/,             loader: 'babel-loader',             exclude: /node_modules/,             query: {                 presets: ['react','es2015','stage-0','stage-1','stage-2','stage-3'],              }         }     ] };   grunt.initconfig({     webpack: {          dev: {             entry: entry,             plugins: commonplugin,             watch: true,              keepalive: true,             stats: {                 timings: true             },               devtool: "#inline-source-map", // here our sourcemap             output: {                 filename: 'app.js',                 path: path.resolve(__dirname, 'out')             },               module: module         },         dist: {             entry: entry,             plugins: commonpluginproduction.concat(new webpack.defineplugin({                     "process.env": {                         // has effect on react lib size                         "node_env": json.stringify("production")                     }                 }),                 //new webpack.optimize.dedupeplugin(),                 uglifyplugin),             output: {                 filename: 'app.min.js',                 path: path.resolve(__dirname, 'out')             },             module: module         }     } });  grunt.loadnpmtasks('grunt-collection'); grunt.registertask('default', ['webpack:dev']); grunt.registertask('deploy', ['webpack:dist']); 

}


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -