diff --git a/templates/ReactSpa/Views/Shared/_Layout.cshtml b/templates/ReactSpa/Views/Shared/_Layout.cshtml index b508e86..a770ceb 100644 --- a/templates/ReactSpa/Views/Shared/_Layout.cshtml +++ b/templates/ReactSpa/Views/Shared/_Layout.cshtml @@ -5,8 +5,9 @@ @ViewData["Title"] - WebApplicationBasic + - + diff --git a/templates/ReactSpa/project.json b/templates/ReactSpa/project.json index fa32892..e22395a 100755 --- a/templates/ReactSpa/project.json +++ b/templates/ReactSpa/project.json @@ -43,8 +43,11 @@ "**.vspscc" ], "scripts": { - "prepublish": [ + "prepare": [ "npm install", + "webpack --config webpack.config.vendor.js" + ], + "prepublish": [ "webpack" ] } diff --git a/templates/ReactSpa/webpack.config.js b/templates/ReactSpa/webpack.config.js index f7583e3..f245d8e 100644 --- a/templates/ReactSpa/webpack.config.js +++ b/templates/ReactSpa/webpack.config.js @@ -12,13 +12,11 @@ module.exports = merge({ module: { loaders: [ { test: /\.ts(x?)$/, include: /ClientApp/, loader: 'babel-loader' }, - { test: /\.ts(x?)$/, include: /ClientApp/, loader: 'ts-loader' }, - { test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' } + { test: /\.ts(x?)$/, include: /ClientApp/, loader: 'ts-loader' } ] }, entry: { main: ['./ClientApp/boot.tsx'], - vendor: ['bootstrap', 'bootstrap/dist/css/bootstrap.css', 'react', 'react-dom', 'react-router', 'style-loader', 'jquery'] }, output: { path: path.join(__dirname, 'wwwroot', 'dist'), @@ -26,8 +24,9 @@ module.exports = merge({ publicPath: '/dist/' }, plugins: [ - new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable) - new webpack.optimize.OccurenceOrderPlugin(), - new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js') // Moves vendor content out of other bundles + new webpack.DllReferencePlugin({ + context: __dirname, + manifest: require('./wwwroot/dist/vendor-manifest.json') + }) ] }, isDevelopment ? devConfig : prodConfig); diff --git a/templates/ReactSpa/webpack.config.prod.js b/templates/ReactSpa/webpack.config.prod.js index 846e8e1..63fa98e 100644 --- a/templates/ReactSpa/webpack.config.prod.js +++ b/templates/ReactSpa/webpack.config.prod.js @@ -10,6 +10,7 @@ module.exports = { }, plugins: [ extractCSS, + new webpack.optimize.OccurenceOrderPlugin(), new webpack.optimize.UglifyJsPlugin({ minimize: true }) ] }; diff --git a/templates/ReactSpa/webpack.config.vendor.js b/templates/ReactSpa/webpack.config.vendor.js new file mode 100644 index 0000000..9f22c26 --- /dev/null +++ b/templates/ReactSpa/webpack.config.vendor.js @@ -0,0 +1,33 @@ +var path = require('path'); +var webpack = require('webpack'); +var ExtractTextPlugin = require('extract-text-webpack-plugin'); +var extractCSS = new ExtractTextPlugin('vendor.css'); + +module.exports = { + resolve: { + extensions: [ '', '.js' ] + }, + module: { + loaders: [ + { test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' }, + { test: /\.css/, loader: extractCSS.extract(['css']) } + ] + }, + entry: { + vendor: ['bootstrap', 'bootstrap/dist/css/bootstrap.css', 'react', 'react-dom', 'react-router', 'style-loader', 'jquery'], + }, + output: { + path: path.join(__dirname, 'wwwroot', 'dist'), + filename: '[name].js', + library: '[name]_[hash]', + }, + plugins: [ + extractCSS, + new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable) + new webpack.optimize.OccurenceOrderPlugin(), + new webpack.DllPlugin({ + path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'), + name: '[name]_[hash]' + }) + ] +};