Skip to content

Commit 808592d

Browse files
Update ReactSpa template to match current patterns
1 parent d1228dc commit 808592d

File tree

8 files changed

+37
-50
lines changed

8 files changed

+37
-50
lines changed

templates/ReactSpa/ClientApp/boot.tsx

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

53
import * as React from 'react';

templates/ReactSpa/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"babel-preset-react": "^6.5.0",
1111
"bootstrap": "^3.3.6",
1212
"css-loader": "^0.23.1",
13-
"extendify": "^1.0.0",
1413
"extract-text-webpack-plugin": "^1.0.1",
1514
"file-loader": "^0.8.5",
1615
"isomorphic-fetch": "^2.2.1",

templates/ReactSpa/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/ReactSpa/webpack.config.dev.js

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 20 additions & 18 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', '.jsx', '.ts', '.tsx' ]
6+
module.exports = {
7+
devtool: isDevBuild ? 'inline-source-map' : null,
8+
entry: { 'main': './ClientApp/boot.tsx' },
9+
resolve: { extensions: [ '', '.js', '.jsx', '.ts', '.tsx' ] },
10+
output: {
11+
path: path.join(__dirname, './wwwroot/dist'),
12+
filename: '[name].js',
13+
publicPath: '/dist/'
1114
},
1215
module: {
1316
loaders: [
1417
{ test: /\.ts(x?)$/, include: /ClientApp/, loader: 'babel-loader' },
15-
{ test: /\.ts(x?)$/, include: /ClientApp/, loader: 'ts-loader?silent=true' }
18+
{ test: /\.tsx?$/, include: /ClientApp/, loader: 'ts', query: { silent: true } },
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.tsx'],
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/ReactSpa/webpack.config.prod.js

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

templates/ReactSpa/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)