mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 01:58:29 +00:00
Update Aurelia SPA template
This commit is contained in:
@@ -1,45 +1,51 @@
|
||||
var isDevBuild = process.argv.indexOf('--env.prod') < 0;
|
||||
var path = require('path');
|
||||
var webpack = require('webpack');
|
||||
var AureliaWebpackPlugin = require('aurelia-webpack-plugin');
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
const { AureliaPlugin } = require('aurelia-webpack-plugin');
|
||||
|
||||
var bundleOutputDir = './wwwroot/dist';
|
||||
module.exports = {
|
||||
resolve: { extensions: [ '.js', '.ts' ] },
|
||||
entry: { 'app': 'aurelia-bootstrapper-webpack' }, // Note: The aurelia-webpack-plugin will add your app's modules to this bundle automatically
|
||||
output: {
|
||||
path: path.resolve(bundleOutputDir),
|
||||
publicPath: '/dist',
|
||||
filename: '[name].js'
|
||||
},
|
||||
module: {
|
||||
loaders: [
|
||||
{ test: /\.ts$/, include: /ClientApp/, loader: 'ts-loader', query: { silent: true } },
|
||||
{ test: /\.html$/, loader: 'html-loader' },
|
||||
{ test: /\.css$/, loaders: [ 'style-loader', isDevBuild ? 'css-loader' : 'css-loader?minimize' ] },
|
||||
{ test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' },
|
||||
{ test: /\.json$/, loader: 'json-loader' }
|
||||
module.exports = ({ prod } = {}) => {
|
||||
const isDevBuild = !prod;
|
||||
const isProdBuild = prod;
|
||||
const bundleOutputDir = './wwwroot/dist';
|
||||
|
||||
return {
|
||||
resolve: {
|
||||
extensions: [".ts", ".js"],
|
||||
modules: ["ClientApp", "node_modules"],
|
||||
},
|
||||
entry: { 'app': 'aurelia-bootstrapper' },
|
||||
output: {
|
||||
path: path.resolve(bundleOutputDir),
|
||||
publicPath: "/dist/",
|
||||
filename: '[name].js'
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{ test: /\.css$/i, use: [isDevBuild ? 'css-loader' : 'css-loader?minimize'] },
|
||||
{ test: /\.html$/i, use: ["html-loader"] },
|
||||
{ test: /\.ts$/i, loaders: ['ts-loader'], exclude: path.resolve(__dirname, 'node_modules') },
|
||||
{ test: /\.json$/i, loader: 'json-loader', exclude: path.resolve(__dirname, 'node_modules') },
|
||||
{ test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader', query: { limit: 8192 } }
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({ IS_DEV_BUILD: JSON.stringify(isDevBuild) }),
|
||||
new webpack.DllReferencePlugin({
|
||||
context: __dirname,
|
||||
manifest: require('./wwwroot/dist/vendor-manifest.json')
|
||||
}),
|
||||
new AureliaPlugin({ aureliaApp: "boot" }),
|
||||
...when(isDevBuild, [
|
||||
new webpack.SourceMapDevToolPlugin({
|
||||
filename: '[file].map',
|
||||
moduleFilenameTemplate: path.relative(bundleOutputDir, '[resourcePath]')
|
||||
})
|
||||
]),
|
||||
...when(isProdBuild, [
|
||||
new webpack.optimize.UglifyJsPlugin()
|
||||
])
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({ IS_DEV_BUILD: JSON.stringify(isDevBuild) }),
|
||||
new webpack.DllReferencePlugin({
|
||||
context: __dirname,
|
||||
manifest: require('./wwwroot/dist/vendor-manifest.json')
|
||||
}),
|
||||
new AureliaWebpackPlugin({
|
||||
root: path.resolve('./'),
|
||||
src: path.resolve('./ClientApp'),
|
||||
baseUrl: '/'
|
||||
})
|
||||
].concat(isDevBuild ? [
|
||||
// Plugins that apply in development builds only
|
||||
new webpack.SourceMapDevToolPlugin({
|
||||
filename: '[file].map', // Remove this line if you prefer inline source maps
|
||||
moduleFilenameTemplate: path.relative(bundleOutputDir, '[resourcePath]') // Point sourcemap entries to the original file locations on disk
|
||||
})
|
||||
] : [
|
||||
// Plugins that apply in production builds only
|
||||
new webpack.optimize.UglifyJsPlugin()
|
||||
])
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
const ensureArray = (config) => config && (Array.isArray(config) ? config : [config]) || []
|
||||
const when = (condition, config, negativeConfig) => condition ? ensureArray(config) : ensureArray(negativeConfig)
|
||||
Reference in New Issue
Block a user