mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 10:08:57 +00:00
Updated ReactReduxSpa template to match current patterns
This commit is contained in:
9
templates/ReactReduxSpa/ClientApp/dist/_placeholder.txt
vendored
Normal file
9
templates/ReactReduxSpa/ClientApp/dist/_placeholder.txt
vendored
Normal file
@@ -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.
|
||||||
@@ -12,3 +12,9 @@ export default <Route component={ Layout }>
|
|||||||
<Route path='(:startDateIndex)' /> { /* Optional route segment that does not affect NavMenu highlighting */ }
|
<Route path='(:startDateIndex)' /> { /* Optional route segment that does not affect NavMenu highlighting */ }
|
||||||
</Route>
|
</Route>
|
||||||
</Route>;
|
</Route>;
|
||||||
|
|
||||||
|
// Allow Hot Module Reloading
|
||||||
|
declare var module: any;
|
||||||
|
if (module.hot) {
|
||||||
|
module.hot.accept();
|
||||||
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export const reducer: Reducer<CounterState> = (state, action) => {
|
|||||||
if (isActionType(action, IncrementCount)) {
|
if (isActionType(action, IncrementCount)) {
|
||||||
return { count: state.count + 1 };
|
return { count: state.count + 1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
// For unrecognized actions (or in cases where actions have no effect), must return the existing state
|
// For unrecognized actions (or in cases where actions have no effect), must return the existing state
|
||||||
// (or default initial state if none was supplied)
|
// (or default initial state if none was supplied)
|
||||||
return state || { count: 0 };
|
return state || { count: 0 };
|
||||||
|
|||||||
@@ -2,9 +2,8 @@
|
|||||||
ViewData["Title"] = "Home Page";
|
ViewData["Title"] = "Home Page";
|
||||||
}
|
}
|
||||||
|
|
||||||
<div id="react-app" asp-prerender-module="ClientApp/boot-server"
|
<div id="react-app" asp-prerender-module="ClientApp/dist/main-server">Loading...</div>
|
||||||
asp-prerender-webpack-config="webpack.config.js">Loading...</div>
|
|
||||||
|
|
||||||
@section scripts {
|
@section scripts {
|
||||||
<script src="~/dist/main.js" asp-append-version="true"></script>
|
<script src="~/dist/main-client.js" asp-append-version="true"></script>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
"bootstrap": "^3.3.6",
|
"bootstrap": "^3.3.6",
|
||||||
"css-loader": "^0.23.1",
|
"css-loader": "^0.23.1",
|
||||||
"domain-task": "^2.0.0",
|
"domain-task": "^2.0.0",
|
||||||
"extendify": "^1.0.0",
|
|
||||||
"extract-text-webpack-plugin": "^1.0.1",
|
"extract-text-webpack-plugin": "^1.0.1",
|
||||||
"file-loader": "^0.8.5",
|
"file-loader": "^0.8.5",
|
||||||
"jquery": "^2.2.1",
|
"jquery": "^2.2.1",
|
||||||
@@ -28,8 +27,9 @@
|
|||||||
"ts-loader": "^0.8.1",
|
"ts-loader": "^0.8.1",
|
||||||
"typescript": "^1.8.2",
|
"typescript": "^1.8.2",
|
||||||
"url-loader": "^0.5.7",
|
"url-loader": "^0.5.7",
|
||||||
"webpack-externals-plugin": "^1.0.0",
|
|
||||||
"webpack": "^1.12.14",
|
"webpack": "^1.12.14",
|
||||||
"webpack-hot-middleware": "^2.10.0"
|
"webpack-externals-plugin": "^1.0.0",
|
||||||
|
"webpack-hot-middleware": "^2.10.0",
|
||||||
|
"webpack-merge": "^0.14.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,16 +51,11 @@
|
|||||||
|
|
||||||
"publishOptions": {
|
"publishOptions": {
|
||||||
"include": [
|
"include": [
|
||||||
".babelrc",
|
|
||||||
"appsettings.json",
|
"appsettings.json",
|
||||||
"ClientApp",
|
"ClientApp/dist",
|
||||||
"node_modules",
|
"node_modules",
|
||||||
"typings",
|
|
||||||
"Views",
|
"Views",
|
||||||
"tsconfig.json",
|
|
||||||
"tsd.json",
|
|
||||||
"web.config",
|
"web.config",
|
||||||
"webpack.*.js",
|
|
||||||
"wwwroot"
|
"wwwroot"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -68,8 +63,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": [
|
"prepublish": [
|
||||||
"npm install",
|
"npm install",
|
||||||
"node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js",
|
"node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod",
|
||||||
"node node_modules/webpack/bin/webpack.js"
|
"node node_modules/webpack/bin/webpack.js --env.prod"
|
||||||
],
|
],
|
||||||
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
|
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -28,7 +28,13 @@ Obj/
|
|||||||
|
|
||||||
# Visual Studio 2015 cache/options directory
|
# Visual Studio 2015 cache/options directory
|
||||||
.vs/
|
.vs/
|
||||||
/wwwroot/dist/
|
/wwwroot/dist/**
|
||||||
|
/ClientApp/dist/**
|
||||||
|
|
||||||
|
# Workaround for https://github.com/aspnet/JavaScriptServices/issues/235
|
||||||
|
!/wwwroot/dist/_placeholder.txt
|
||||||
|
!/ClientApp/dist/_placeholder.txt
|
||||||
|
|
||||||
|
|
||||||
# MSTest test Results
|
# MSTest test Results
|
||||||
[Tt]est[Rr]esult*/
|
[Tt]est[Rr]esult*/
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
devtool: 'inline-source-map'
|
|
||||||
};
|
|
||||||
@@ -1,36 +1,60 @@
|
|||||||
|
var isDevBuild = process.argv.indexOf('--env.prod') < 0;
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var webpack = require('webpack');
|
var webpack = require('webpack');
|
||||||
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||||
var merge = require('extendify')({ isDeep: true, arrays: 'concat' });
|
var nodeExternals = require('webpack-node-externals');
|
||||||
var devConfig = require('./webpack.config.dev');
|
var merge = require('webpack-merge');
|
||||||
var prodConfig = require('./webpack.config.prod');
|
var allFilenamesExceptJavaScript = /\.(?!js(\?|$))([^.]+(\?|$))/;
|
||||||
var isDevelopment = process.env.ASPNETCORE_ENVIRONMENT === 'Development';
|
|
||||||
var extractCSS = new ExtractTextPlugin('site.css');
|
|
||||||
|
|
||||||
module.exports = merge({
|
// Configuration in common to both client-side and server-side bundles
|
||||||
resolve: {
|
var sharedConfig = () => ({
|
||||||
extensions: [ '', '.js', '.jsx', '.ts', '.tsx' ]
|
resolve: { extensions: [ '', '.js', '.jsx', '.ts', '.tsx' ] },
|
||||||
|
output: {
|
||||||
|
filename: '[name].js',
|
||||||
|
publicPath: '/dist/' // Webpack dev middleware, if enabled, handles requests for this URL prefix
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
loaders: [
|
loaders: [
|
||||||
{ test: /\.ts(x?)$/, include: /ClientApp/, loader: 'babel-loader' },
|
{ test: /\.tsx?$/, include: /ClientApp/, loader: 'babel-loader' },
|
||||||
{ test: /\.ts(x?)$/, include: /ClientApp/, loader: 'ts-loader?silent=true' },
|
{ test: /\.tsx?$/, include: /ClientApp/, loader: 'ts', query: { silent: true } }
|
||||||
{ test: /\.css/, loader: extractCSS.extract(['css']) }
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Configuration for client-side bundle suitable for running in browsers
|
||||||
|
var clientBundleConfig = merge(sharedConfig(), {
|
||||||
|
entry: { 'main-client': './ClientApp/boot-client.tsx' },
|
||||||
|
module: {
|
||||||
|
loaders: [
|
||||||
|
{ test: /\.css$/, loader: ExtractTextPlugin.extract(['css']) },
|
||||||
|
{ test: /\.(png|jpg|jpeg|gif|svg)$/, loader: 'url', query: { limit: 25000 } }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
entry: {
|
output: { path: path.join(__dirname, './wwwroot/dist') },
|
||||||
main: ['./ClientApp/boot-client.tsx'],
|
devtool: isDevBuild ? 'inline-source-map' : null,
|
||||||
},
|
|
||||||
output: {
|
|
||||||
path: path.join(__dirname, 'wwwroot', 'dist'),
|
|
||||||
filename: '[name].js',
|
|
||||||
publicPath: '/dist/'
|
|
||||||
},
|
|
||||||
plugins: [
|
plugins: [
|
||||||
extractCSS,
|
new ExtractTextPlugin('site.css'),
|
||||||
new webpack.DllReferencePlugin({
|
new webpack.DllReferencePlugin({
|
||||||
context: __dirname,
|
context: __dirname,
|
||||||
manifest: require('./wwwroot/dist/vendor-manifest.json')
|
manifest: require('./wwwroot/dist/vendor-manifest.json')
|
||||||
})
|
})
|
||||||
]
|
].concat(isDevBuild ? [] : [
|
||||||
}, isDevelopment ? devConfig : prodConfig);
|
// Plugins that apply in production builds only
|
||||||
|
new webpack.optimize.OccurenceOrderPlugin(),
|
||||||
|
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
|
||||||
|
])
|
||||||
|
});
|
||||||
|
|
||||||
|
// Configuration for server-side (prerendering) bundle suitable for running in Node
|
||||||
|
var serverBundleConfig = merge(sharedConfig(), {
|
||||||
|
entry: { 'main-server': './ClientApp/boot-server.tsx' },
|
||||||
|
output: {
|
||||||
|
libraryTarget: 'commonjs',
|
||||||
|
path: path.join(__dirname, './ClientApp/dist')
|
||||||
|
},
|
||||||
|
target: 'node',
|
||||||
|
devtool: 'inline-source-map',
|
||||||
|
externals: [nodeExternals({ whitelist: [allFilenamesExceptJavaScript] })] // Don't bundle .js files from node_modules
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = [clientBundleConfig, serverBundleConfig];
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
var webpack = require('webpack');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
plugins: [
|
|
||||||
new webpack.optimize.OccurenceOrderPlugin(),
|
|
||||||
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }),
|
|
||||||
new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"production"' })
|
|
||||||
]
|
|
||||||
};
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
|
var isDevBuild = process.argv.indexOf('--env.prod') < 0;
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var webpack = require('webpack');
|
var webpack = require('webpack');
|
||||||
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||||
var extractCSS = new ExtractTextPlugin('vendor.css');
|
var extractCSS = new ExtractTextPlugin('vendor.css');
|
||||||
var isDevelopment = process.env.ASPNETCORE_ENVIRONMENT === 'Development';
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
resolve: {
|
resolve: {
|
||||||
@@ -10,12 +10,12 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
loaders: [
|
loaders: [
|
||||||
{ test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' },
|
{ test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, loader: 'url-loader?limit=100000' },
|
||||||
{ test: /\.css/, loader: extractCSS.extract(['css']) }
|
{ test: /\.css(\?|$)/, loader: extractCSS.extract(['css']) }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
entry: {
|
entry: {
|
||||||
vendor: ['bootstrap', 'bootstrap/dist/css/bootstrap.css', 'react', 'react-dom', 'react-router', 'style-loader', 'jquery'],
|
vendor: ['bootstrap', 'bootstrap/dist/css/bootstrap.css', 'domain-task', 'react', 'react-dom', 'react-router', 'redux', 'redux-thunk', 'react-router-redux', 'redux-typed', 'style-loader', 'jquery'],
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
path: path.join(__dirname, 'wwwroot', 'dist'),
|
path: path.join(__dirname, 'wwwroot', 'dist'),
|
||||||
@@ -29,9 +29,11 @@ module.exports = {
|
|||||||
new webpack.DllPlugin({
|
new webpack.DllPlugin({
|
||||||
path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),
|
path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),
|
||||||
name: '[name]_[hash]'
|
name: '[name]_[hash]'
|
||||||
|
}),
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
'process.env.NODE_ENV': isDevBuild ? '"development"' : '"production"'
|
||||||
})
|
})
|
||||||
].concat(isDevelopment ? [] : [
|
].concat(isDevBuild ? [] : [
|
||||||
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }),
|
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
|
||||||
new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"production"' })
|
|
||||||
])
|
])
|
||||||
};
|
};
|
||||||
|
|||||||
9
templates/ReactReduxSpa/wwwroot/dist/_placeholder.txt
vendored
Normal file
9
templates/ReactReduxSpa/wwwroot/dist/_placeholder.txt
vendored
Normal file
@@ -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.
|
||||||
Reference in New Issue
Block a user