mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Make Aurelia webpack config as consistent as possible with the other templates
This commit is contained in:
@@ -1,30 +1,28 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const { AureliaPlugin } = require('aurelia-webpack-plugin');
|
const { AureliaPlugin } = require('aurelia-webpack-plugin');
|
||||||
|
const bundleOutputDir = './wwwroot/dist';
|
||||||
|
|
||||||
module.exports = ({ prod } = {}) => {
|
module.exports = (env) => {
|
||||||
const isDevBuild = !prod;
|
const isDevBuild = !(env && env.prod);
|
||||||
const isProdBuild = prod;
|
return [{
|
||||||
const bundleOutputDir = './wwwroot/dist';
|
stats: { modules: false },
|
||||||
|
|
||||||
return {
|
|
||||||
resolve: {
|
|
||||||
extensions: [".ts", ".js"],
|
|
||||||
modules: ["ClientApp", "node_modules"],
|
|
||||||
},
|
|
||||||
entry: { 'app': 'aurelia-bootstrapper' },
|
entry: { 'app': 'aurelia-bootstrapper' },
|
||||||
|
resolve: {
|
||||||
|
extensions: ['.ts', '.js'],
|
||||||
|
modules: ['ClientApp', 'node_modules'],
|
||||||
|
},
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(bundleOutputDir),
|
path: path.resolve(bundleOutputDir),
|
||||||
publicPath: "/dist/",
|
publicPath: '/dist/',
|
||||||
filename: '[name].js'
|
filename: '[name].js'
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{ test: /\.css$/i, use: [isDevBuild ? 'css-loader' : 'css-loader?minimize'] },
|
{ test: /\.ts$/i, include: /ClientApp/, use: 'ts-loader?silent=true' },
|
||||||
{ test: /\.html$/i, use: ["html-loader"] },
|
{ test: /\.html$/i, use: 'html-loader' },
|
||||||
{ test: /\.ts$/i, loaders: ['ts-loader'], exclude: path.resolve(__dirname, 'node_modules') },
|
{ test: /\.css$/i, use: isDevBuild ? 'css-loader' : 'css-loader?minimize' },
|
||||||
{ test: /\.json$/i, loader: 'json-loader', exclude: path.resolve(__dirname, 'node_modules') },
|
{ test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000' }
|
||||||
{ test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader', query: { limit: 8192 } }
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
@@ -33,19 +31,14 @@ module.exports = ({ prod } = {}) => {
|
|||||||
context: __dirname,
|
context: __dirname,
|
||||||
manifest: require('./wwwroot/dist/vendor-manifest.json')
|
manifest: require('./wwwroot/dist/vendor-manifest.json')
|
||||||
}),
|
}),
|
||||||
new AureliaPlugin({ aureliaApp: "boot" }),
|
new AureliaPlugin({ aureliaApp: 'boot' })
|
||||||
...when(isDevBuild, [
|
].concat(isDevBuild ? [
|
||||||
new webpack.SourceMapDevToolPlugin({
|
new webpack.SourceMapDevToolPlugin({
|
||||||
filename: '[file].map',
|
filename: '[file].map', // Remove this line if you prefer inline source maps
|
||||||
moduleFilenameTemplate: path.relative(bundleOutputDir, '[resourcePath]')
|
moduleFilenameTemplate: path.relative(bundleOutputDir, '[resourcePath]') // Point sourcemap entries to the original file locations on disk
|
||||||
})
|
})
|
||||||
]),
|
] : [
|
||||||
...when(isProdBuild, [
|
|
||||||
new webpack.optimize.UglifyJsPlugin()
|
new webpack.optimize.UglifyJsPlugin()
|
||||||
])
|
])
|
||||||
]
|
}];
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ensureArray = (config) => config && (Array.isArray(config) ? config : [config]) || []
|
|
||||||
const when = (condition, config, negativeConfig) => condition ? ensureArray(config) : ensureArray(negativeConfig)
|
|
||||||
@@ -6,7 +6,8 @@ var extractCSS = new ExtractTextPlugin('vendor.css');
|
|||||||
module.exports = ({ prod } = {}) => {
|
module.exports = ({ prod } = {}) => {
|
||||||
const isDevBuild = !prod;
|
const isDevBuild = !prod;
|
||||||
|
|
||||||
return {
|
return [{
|
||||||
|
stats: { modules: false },
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.js']
|
extensions: ['.js']
|
||||||
},
|
},
|
||||||
@@ -51,5 +52,5 @@ module.exports = ({ prod } = {}) => {
|
|||||||
].concat(isDevBuild ? [] : [
|
].concat(isDevBuild ? [] : [
|
||||||
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
|
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
|
||||||
])
|
])
|
||||||
}
|
}]
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user