Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Commit e3a8c13

Browse files
Make Aurelia webpack config as consistent as possible with the other templates
1 parent 37df309 commit e3a8c13

File tree

2 files changed

+26
-32
lines changed

2 files changed

+26
-32
lines changed
Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
11
const path = require('path');
22
const webpack = require('webpack');
33
const { AureliaPlugin } = require('aurelia-webpack-plugin');
4+
const bundleOutputDir = './wwwroot/dist';
45

5-
module.exports = ({ prod } = {}) => {
6-
const isDevBuild = !prod;
7-
const isProdBuild = prod;
8-
const bundleOutputDir = './wwwroot/dist';
9-
10-
return {
6+
module.exports = (env) => {
7+
const isDevBuild = !(env && env.prod);
8+
return [{
9+
stats: { modules: false },
10+
entry: { 'app': 'aurelia-bootstrapper' },
1111
resolve: {
12-
extensions: [".ts", ".js"],
13-
modules: ["ClientApp", "node_modules"],
12+
extensions: ['.ts', '.js'],
13+
modules: ['ClientApp', 'node_modules'],
1414
},
15-
entry: { 'app': 'aurelia-bootstrapper' },
1615
output: {
1716
path: path.resolve(bundleOutputDir),
18-
publicPath: "/dist/",
17+
publicPath: '/dist/',
1918
filename: '[name].js'
2019
},
2120
module: {
2221
rules: [
23-
{ test: /\.css$/i, use: [isDevBuild ? 'css-loader' : 'css-loader?minimize'] },
24-
{ test: /\.html$/i, use: ["html-loader"] },
25-
{ test: /\.ts$/i, loaders: ['ts-loader'], exclude: path.resolve(__dirname, 'node_modules') },
26-
{ test: /\.json$/i, loader: 'json-loader', exclude: path.resolve(__dirname, 'node_modules') },
27-
{ test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader', query: { limit: 8192 } }
22+
{ test: /\.ts$/i, include: /ClientApp/, use: 'ts-loader?silent=true' },
23+
{ test: /\.html$/i, use: 'html-loader' },
24+
{ test: /\.css$/i, use: isDevBuild ? 'css-loader' : 'css-loader?minimize' },
25+
{ test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000' }
2826
]
2927
},
3028
plugins: [
@@ -33,19 +31,14 @@ module.exports = ({ prod } = {}) => {
3331
context: __dirname,
3432
manifest: require('./wwwroot/dist/vendor-manifest.json')
3533
}),
36-
new AureliaPlugin({ aureliaApp: "boot" }),
37-
...when(isDevBuild, [
38-
new webpack.SourceMapDevToolPlugin({
39-
filename: '[file].map',
40-
moduleFilenameTemplate: path.relative(bundleOutputDir, '[resourcePath]')
41-
})
42-
]),
43-
...when(isProdBuild, [
44-
new webpack.optimize.UglifyJsPlugin()
45-
])
46-
]
47-
};
34+
new AureliaPlugin({ aureliaApp: 'boot' })
35+
].concat(isDevBuild ? [
36+
new webpack.SourceMapDevToolPlugin({
37+
filename: '[file].map', // Remove this line if you prefer inline source maps
38+
moduleFilenameTemplate: path.relative(bundleOutputDir, '[resourcePath]') // Point sourcemap entries to the original file locations on disk
39+
})
40+
] : [
41+
new webpack.optimize.UglifyJsPlugin()
42+
])
43+
}];
4844
}
49-
50-
const ensureArray = (config) => config && (Array.isArray(config) ? config : [config]) || []
51-
const when = (condition, config, negativeConfig) => condition ? ensureArray(config) : ensureArray(negativeConfig)

templates/AureliaSpa/webpack.config.vendor.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ var extractCSS = new ExtractTextPlugin('vendor.css');
66
module.exports = ({ prod } = {}) => {
77
const isDevBuild = !prod;
88

9-
return {
9+
return [{
10+
stats: { modules: false },
1011
resolve: {
1112
extensions: ['.js']
1213
},
@@ -51,5 +52,5 @@ module.exports = ({ prod } = {}) => {
5152
].concat(isDevBuild ? [] : [
5253
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
5354
])
54-
}
55+
}]
5556
};

0 commit comments

Comments
 (0)