mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 10:08:57 +00:00
Simplify AureliaSpa's webpack.config.js
This commit is contained in:
@@ -2,55 +2,48 @@ 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 AureliaWebpackPlugin = require('aurelia-webpack-plugin');
|
var AureliaWebpackPlugin = require('aurelia-webpack-plugin');
|
||||||
var srcDir = path.resolve('./ClientApp');
|
|
||||||
var rootDir = path.resolve();
|
|
||||||
var outDir = path.resolve('./wwwroot/dist');
|
|
||||||
var baseUrl = '/';
|
|
||||||
var project = require('./package.json');
|
|
||||||
var aureliaModules = Object.keys(project.dependencies).filter(dep => dep.startsWith('aurelia-'));
|
|
||||||
|
|
||||||
// Configuration for client-side bundle suitable for running in browsers
|
module.exports = {
|
||||||
var clientBundleConfig = {
|
|
||||||
resolve: { extensions: [ '.js', '.ts' ] },
|
resolve: { extensions: [ '.js', '.ts' ] },
|
||||||
devtool: isDevBuild ? 'inline-source-map' : null,
|
devtool: isDevBuild ? 'inline-source-map' : null,
|
||||||
entry: {
|
entry: {
|
||||||
'app': [], // <-- this array will be filled by the aurelia-webpack-plugin
|
'app': [], // <-- this array will be filled by the aurelia-webpack-plugin
|
||||||
'aurelia-modules': aureliaModules
|
'aurelia-modules': [
|
||||||
|
'aurelia-bootstrapper-webpack',
|
||||||
|
'aurelia-event-aggregator',
|
||||||
|
'aurelia-fetch-client',
|
||||||
|
'aurelia-framework',
|
||||||
|
'aurelia-history-browser',
|
||||||
|
'aurelia-loader-webpack',
|
||||||
|
'aurelia-logging-console',
|
||||||
|
'aurelia-pal-browser',
|
||||||
|
'aurelia-polyfills',
|
||||||
|
'aurelia-route-recognizer',
|
||||||
|
'aurelia-router',
|
||||||
|
'aurelia-templating-binding',
|
||||||
|
'aurelia-templating-resources',
|
||||||
|
'aurelia-templating-router'
|
||||||
|
]
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
path: outDir,
|
path: path.resolve('./wwwroot/dist'),
|
||||||
publicPath: '/dist',
|
publicPath: '/dist',
|
||||||
filename: '[name]-bundle.js'
|
filename: '[name]-bundle.js'
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
loaders: [
|
loaders: [
|
||||||
{
|
{ test: /\.ts$/, include: /ClientApp/, loader: 'ts', query: {silent: true} },
|
||||||
test: /\.ts$/,
|
{ test: /\.html$/, loader: 'html-loader' },
|
||||||
include: /ClientApp/,
|
{ test: /\.css$/, loaders: ['style-loader', 'css-loader'] },
|
||||||
loader: 'ts',
|
{ test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' }
|
||||||
query: {silent: true}
|
|
||||||
}, {
|
|
||||||
test: /\.html$/,
|
|
||||||
exclude: /index\.html$/,
|
|
||||||
loader: 'html-loader'
|
|
||||||
}, {
|
|
||||||
test: /\.css$/,
|
|
||||||
loaders: ['style-loader', 'css-loader']
|
|
||||||
}, {
|
|
||||||
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
|
|
||||||
loader: 'url-loader?limit=100000'
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.ProvidePlugin({
|
new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // because Bootstrap expects $ and jQuery to be globals
|
||||||
$: 'jquery', // because 'bootstrap' by Twitter depends on this
|
|
||||||
jQuery: 'jquery'
|
|
||||||
}),
|
|
||||||
new AureliaWebpackPlugin({
|
new AureliaWebpackPlugin({
|
||||||
root: rootDir,
|
root: path.resolve('./'),
|
||||||
src: srcDir,
|
src: path.resolve('./ClientApp'),
|
||||||
baseUrl: baseUrl
|
baseUrl: '/'
|
||||||
}),
|
}),
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
new webpack.optimize.CommonsChunkPlugin({
|
||||||
name: ['aurelia-modules']
|
name: ['aurelia-modules']
|
||||||
@@ -60,5 +53,3 @@ var clientBundleConfig = {
|
|||||||
new webpack.optimize.UglifyJsPlugin()
|
new webpack.optimize.UglifyJsPlugin()
|
||||||
])
|
])
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = [clientBundleConfig];
|
|
||||||
|
|||||||
Reference in New Issue
Block a user