Skip to content

Commit d1228dc

Browse files
Update KnockoutSpa template to match current patterns
1 parent 09b4135 commit d1228dc

File tree

8 files changed

+38
-51
lines changed

8 files changed

+38
-51
lines changed

templates/KnockoutSpa/ClientApp/boot.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import 'bootstrap';
2-
import 'bootstrap/dist/css/bootstrap.css';
31
import './css/site.css';
42
import * as ko from 'knockout';
53
import { createHistory } from 'history';

templates/KnockoutSpa/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"bundle-loader": "^0.5.4",
88
"crossroads": "^0.12.2",
99
"css-loader": "^0.23.1",
10-
"extendify": "^1.0.0",
1110
"extract-text-webpack-plugin": "^1.0.1",
1211
"file-loader": "^0.8.5",
1312
"history": "^2.0.1",

templates/KnockoutSpa/template_gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ Obj/
2828

2929
# Visual Studio 2015 cache/options directory
3030
.vs/
31-
/wwwroot/dist/
31+
/wwwroot/dist/**
32+
33+
# Workaround for https://github.com/aspnet/JavaScriptServices/issues/235
34+
!/wwwroot/dist/_placeholder.txt
3235

3336
# MSTest test Results
3437
[Tt]est[Rr]esult*/

templates/KnockoutSpa/webpack.config.dev.js

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
1+
var isDevBuild = process.argv.indexOf('--env.prod') < 0;
12
var path = require('path');
23
var webpack = require('webpack');
3-
var merge = require('extendify')({ isDeep: true, arrays: 'concat' });
4-
var devConfig = require('./webpack.config.dev');
5-
var prodConfig = require('./webpack.config.prod');
6-
var isDevelopment = process.env.ASPNETCORE_ENVIRONMENT === 'Development';
4+
var ExtractTextPlugin = require('extract-text-webpack-plugin');
75

8-
module.exports = merge({
9-
resolve: {
10-
extensions: [ '', '.js', '.ts' ]
6+
module.exports = {
7+
devtool: isDevBuild ? 'inline-source-map' : null,
8+
entry: { 'main': './ClientApp/boot.ts' },
9+
resolve: { extensions: [ '', '.js', '.ts' ] },
10+
output: {
11+
path: path.join(__dirname, './wwwroot/dist'),
12+
filename: '[name].js',
13+
publicPath: '/dist/'
1114
},
1215
module: {
1316
loaders: [
14-
{ test: /\.ts(x?)$/, include: /ClientApp/, loader: 'ts-loader?silent=true' },
15-
{ test: /\.html$/, loader: 'raw-loader' }
17+
{ test: /\.ts$/, include: /ClientApp/, loader: 'ts', query: { silent: true } },
18+
{ test: /\.html$/, loader: 'raw' },
19+
{ test: /\.css$/, loader: isDevBuild ? 'style!css' : ExtractTextPlugin.extract(['css']) },
20+
{ test: /\.(png|jpg|jpeg|gif|svg)$/, loader: 'url', query: { limit: 25000 } }
1621
]
1722
},
18-
entry: {
19-
main: ['./ClientApp/boot.ts'],
20-
},
21-
output: {
22-
path: path.join(__dirname, 'wwwroot', 'dist'),
23-
filename: '[name].js',
24-
publicPath: '/dist/'
25-
},
2623
plugins: [
2724
new webpack.DllReferencePlugin({
2825
context: __dirname,
2926
manifest: require('./wwwroot/dist/vendor-manifest.json')
3027
})
31-
]
32-
}, isDevelopment ? devConfig : prodConfig);
28+
].concat(isDevBuild ? [] : [
29+
// Plugins that apply in production builds only
30+
new webpack.optimize.OccurenceOrderPlugin(),
31+
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }),
32+
new ExtractTextPlugin('site.css')
33+
])
34+
};

templates/KnockoutSpa/webpack.config.prod.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

templates/KnockoutSpa/webpack.config.vendor.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1+
var isDevBuild = process.argv.indexOf('--env.prod') < 0;
12
var path = require('path');
23
var webpack = require('webpack');
34
var ExtractTextPlugin = require('extract-text-webpack-plugin');
45
var extractCSS = new ExtractTextPlugin('vendor.css');
5-
var isDevelopment = process.env.ASPNETCORE_ENVIRONMENT === 'Development';
66

77
module.exports = {
88
resolve: {
99
extensions: [ '', '.js' ]
1010
},
1111
module: {
1212
loaders: [
13-
{ test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' },
14-
{ test: /\.css/, loader: extractCSS.extract(['css']) }
13+
{ test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, loader: 'url-loader?limit=100000' },
14+
{ test: /\.css(\?|$)/, loader: extractCSS.extract(['css']) }
1515
]
1616
},
1717
entry: {
@@ -30,7 +30,7 @@ module.exports = {
3030
path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),
3131
name: '[name]_[hash]'
3232
})
33-
].concat(isDevelopment ? [] : [
33+
].concat(isDevBuild ? [] : [
3434
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
3535
])
3636
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
------------------------------------------------------------------
2+
Don't delete this file. Do include it in your source control repo.
3+
------------------------------------------------------------------
4+
5+
This file exists as a workaround for https://github.com/dotnet/cli/issues/1396
6+
('dotnet publish' does not publish any directories that didn't exist or were
7+
empty before the publish script started).
8+
9+
Hopefully, this can be removed after the move to the new MSBuild.

0 commit comments

Comments
 (0)