diff --git a/templates/KnockoutSpa/ClientApp/boot.ts b/templates/KnockoutSpa/ClientApp/boot.ts index 66740eb..8775c95 100644 --- a/templates/KnockoutSpa/ClientApp/boot.ts +++ b/templates/KnockoutSpa/ClientApp/boot.ts @@ -1,5 +1,3 @@ -import 'bootstrap'; -import 'bootstrap/dist/css/bootstrap.css'; import './css/site.css'; import * as ko from 'knockout'; import { createHistory } from 'history'; diff --git a/templates/KnockoutSpa/package.json b/templates/KnockoutSpa/package.json index bff49e0..6a92079 100644 --- a/templates/KnockoutSpa/package.json +++ b/templates/KnockoutSpa/package.json @@ -7,7 +7,6 @@ "bundle-loader": "^0.5.4", "crossroads": "^0.12.2", "css-loader": "^0.23.1", - "extendify": "^1.0.0", "extract-text-webpack-plugin": "^1.0.1", "file-loader": "^0.8.5", "history": "^2.0.1", diff --git a/templates/KnockoutSpa/template_gitignore b/templates/KnockoutSpa/template_gitignore index 2ee8e59..dacd256 100644 --- a/templates/KnockoutSpa/template_gitignore +++ b/templates/KnockoutSpa/template_gitignore @@ -28,7 +28,10 @@ Obj/ # Visual Studio 2015 cache/options directory .vs/ -/wwwroot/dist/ +/wwwroot/dist/** + +# Workaround for https://github.com/aspnet/JavaScriptServices/issues/235 +!/wwwroot/dist/_placeholder.txt # MSTest test Results [Tt]est[Rr]esult*/ diff --git a/templates/KnockoutSpa/webpack.config.dev.js b/templates/KnockoutSpa/webpack.config.dev.js deleted file mode 100644 index fd41ce6..0000000 --- a/templates/KnockoutSpa/webpack.config.dev.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - devtool: 'inline-source-map', - module: { - loaders: [ - { test: /\.css/, loader: 'style!css' } - ] - } -}; diff --git a/templates/KnockoutSpa/webpack.config.js b/templates/KnockoutSpa/webpack.config.js index 9762ae8..352ab3c 100644 --- a/templates/KnockoutSpa/webpack.config.js +++ b/templates/KnockoutSpa/webpack.config.js @@ -1,32 +1,34 @@ +var isDevBuild = process.argv.indexOf('--env.prod') < 0; var path = require('path'); var webpack = require('webpack'); -var merge = require('extendify')({ isDeep: true, arrays: 'concat' }); -var devConfig = require('./webpack.config.dev'); -var prodConfig = require('./webpack.config.prod'); -var isDevelopment = process.env.ASPNETCORE_ENVIRONMENT === 'Development'; +var ExtractTextPlugin = require('extract-text-webpack-plugin'); -module.exports = merge({ - resolve: { - extensions: [ '', '.js', '.ts' ] +module.exports = { + devtool: isDevBuild ? 'inline-source-map' : null, + entry: { 'main': './ClientApp/boot.ts' }, + resolve: { extensions: [ '', '.js', '.ts' ] }, + output: { + path: path.join(__dirname, './wwwroot/dist'), + filename: '[name].js', + publicPath: '/dist/' }, module: { loaders: [ - { test: /\.ts(x?)$/, include: /ClientApp/, loader: 'ts-loader?silent=true' }, - { test: /\.html$/, loader: 'raw-loader' } + { test: /\.ts$/, include: /ClientApp/, loader: 'ts', query: { silent: true } }, + { test: /\.html$/, loader: 'raw' }, + { test: /\.css$/, loader: isDevBuild ? 'style!css' : ExtractTextPlugin.extract(['css']) }, + { test: /\.(png|jpg|jpeg|gif|svg)$/, loader: 'url', query: { limit: 25000 } } ] }, - entry: { - main: ['./ClientApp/boot.ts'], - }, - output: { - path: path.join(__dirname, 'wwwroot', 'dist'), - filename: '[name].js', - publicPath: '/dist/' - }, plugins: [ new webpack.DllReferencePlugin({ context: __dirname, manifest: require('./wwwroot/dist/vendor-manifest.json') }) - ] -}, isDevelopment ? devConfig : prodConfig); + ].concat(isDevBuild ? [] : [ + // Plugins that apply in production builds only + new webpack.optimize.OccurenceOrderPlugin(), + new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }), + new ExtractTextPlugin('site.css') + ]) +}; diff --git a/templates/KnockoutSpa/webpack.config.prod.js b/templates/KnockoutSpa/webpack.config.prod.js deleted file mode 100644 index 068da38..0000000 --- a/templates/KnockoutSpa/webpack.config.prod.js +++ /dev/null @@ -1,16 +0,0 @@ -var webpack = require('webpack'); -var ExtractTextPlugin = require('extract-text-webpack-plugin'); -var extractCSS = new ExtractTextPlugin('site.css'); - -module.exports = { - module: { - loaders: [ - { test: /\.css/, loader: extractCSS.extract(['css']) }, - ] - }, - plugins: [ - extractCSS, - new webpack.optimize.OccurenceOrderPlugin(), - new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }) - ] -}; diff --git a/templates/KnockoutSpa/webpack.config.vendor.js b/templates/KnockoutSpa/webpack.config.vendor.js index 6c212ac..bc734d9 100644 --- a/templates/KnockoutSpa/webpack.config.vendor.js +++ b/templates/KnockoutSpa/webpack.config.vendor.js @@ -1,8 +1,8 @@ +var isDevBuild = process.argv.indexOf('--env.prod') < 0; var path = require('path'); var webpack = require('webpack'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); var extractCSS = new ExtractTextPlugin('vendor.css'); -var isDevelopment = process.env.ASPNETCORE_ENVIRONMENT === 'Development'; module.exports = { resolve: { @@ -10,8 +10,8 @@ module.exports = { }, module: { loaders: [ - { test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' }, - { test: /\.css/, loader: extractCSS.extract(['css']) } + { test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, loader: 'url-loader?limit=100000' }, + { test: /\.css(\?|$)/, loader: extractCSS.extract(['css']) } ] }, entry: { @@ -30,7 +30,7 @@ module.exports = { path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'), name: '[name]_[hash]' }) - ].concat(isDevelopment ? [] : [ + ].concat(isDevBuild ? [] : [ new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }) ]) }; diff --git a/templates/KnockoutSpa/wwwroot/dist/_placeholder.txt b/templates/KnockoutSpa/wwwroot/dist/_placeholder.txt new file mode 100644 index 0000000..b22cc15 --- /dev/null +++ b/templates/KnockoutSpa/wwwroot/dist/_placeholder.txt @@ -0,0 +1,9 @@ +------------------------------------------------------------------ +Don't delete this file. Do include it in your source control repo. +------------------------------------------------------------------ + +This file exists as a workaround for https://github.com/dotnet/cli/issues/1396 +('dotnet publish' does not publish any directories that didn't exist or were +empty before the publish script started). + +Hopefully, this can be removed after the move to the new MSBuild.