Skip to content

Commit acfb253

Browse files
Change AureliaSpa to use vendor bundle like the other templates
1 parent 3087352 commit acfb253

File tree

6 files changed

+70
-33
lines changed

6 files changed

+70
-33
lines changed

templates/AureliaSpa/Views/Home/Index.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
<div aurelia-app="boot">Loading...</div>
66

77
@section scripts {
8-
<script type="text/javascript" src="~/dist/aurelia-modules-bundle.js" asp-append-version="true"></script>
9-
<script type="text/javascript" src="~/dist/app-bundle.js" asp-append-version="true"></script>
8+
<script type="text/javascript" src="~/dist/vendor.js" asp-append-version="true"></script>
9+
<script type="text/javascript" src="~/dist/app.js" asp-append-version="true"></script>
1010
}

templates/AureliaSpa/Views/Shared/_Layout.cshtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<meta charset="utf-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>@ViewData["Title"] - Aurelia</title>
7+
8+
<link rel="stylesheet" href="~/dist/vendor.css" asp-append-version="true" />
79
</head>
810
<body>
911
@RenderBody()

templates/AureliaSpa/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"css": "^2.2.1",
2929
"css-loader": "^0.25.0",
3030
"expose-loader": "^0.7.1",
31+
"extract-text-webpack-plugin": "^2.0.0-beta.4",
3132
"file-loader": "^0.9.0",
3233
"html-loader": "^0.4.4",
3334
"html-webpack-plugin": "^2.22.0",
@@ -37,7 +38,7 @@
3738
"ts-loader": "^0.8.2",
3839
"typescript": "^2.0.0",
3940
"url-loader": "^0.5.7",
40-
"webpack": "2.1.0-beta.22",
41+
"webpack": "^2.1.0-beta.25",
4142
"webpack-hot-middleware": "^2.10.0"
4243
}
4344
}

templates/AureliaSpa/project.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"scripts": {
6363
"prepublish": [
6464
"npm install",
65+
"node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod",
6566
"node node_modules/webpack/bin/webpack.js --env.prod"
6667
],
6768
"postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"

templates/AureliaSpa/webpack.config.js

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,32 @@ var webpack = require('webpack');
44
var AureliaWebpackPlugin = require('aurelia-webpack-plugin');
55

66
module.exports = {
7-
resolve: { extensions: [ '.js', '.ts' ] },
8-
devtool: isDevBuild ? 'inline-source-map' : null,
9-
entry: {
10-
'app': [], // <-- this array will be filled by the aurelia-webpack-plugin
11-
'aurelia-modules': [
12-
'aurelia-bootstrapper-webpack',
13-
'aurelia-event-aggregator',
14-
'aurelia-fetch-client',
15-
'aurelia-framework',
16-
'aurelia-history-browser',
17-
'aurelia-loader-webpack',
18-
'aurelia-logging-console',
19-
'aurelia-pal-browser',
20-
'aurelia-polyfills',
21-
'aurelia-route-recognizer',
22-
'aurelia-router',
23-
'aurelia-templating-binding',
24-
'aurelia-templating-resources',
25-
'aurelia-templating-router'
26-
]
27-
},
7+
resolve: { extensions: [ '.js', '.ts' ] },
8+
devtool: isDevBuild ? 'inline-source-map' : null,
9+
entry: { 'app': 'aurelia-bootstrapper-webpack' }, // Note: The aurelia-webpack-plugin will add your app's modules to this bundle automatically
2810
output: {
2911
path: path.resolve('./wwwroot/dist'),
3012
publicPath: '/dist',
31-
filename: '[name]-bundle.js'
13+
filename: '[name].js'
3214
},
3315
module: {
3416
loaders: [
35-
{ test: /\.ts$/, include: /ClientApp/, loader: 'ts', query: {silent: true} },
36-
{ test: /\.html$/, loader: 'html-loader' },
37-
{ test: /\.css$/, loaders: ['style-loader', 'css-loader'] },
17+
{ test: /\.ts$/, include: /ClientApp/, loader: 'ts', query: { silent: true } },
18+
{ test: /\.html$/, loader: 'html' },
19+
{ test: /\.css$/, loaders: [ 'style', 'css' ] },
3820
{ test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' }
3921
]
4022
},
4123
plugins: [
42-
new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // because Bootstrap expects $ and jQuery to be globals
24+
new webpack.DllReferencePlugin({
25+
context: __dirname,
26+
manifest: require('./wwwroot/dist/vendor-manifest.json')
27+
}),
4328
new AureliaWebpackPlugin({
4429
root: path.resolve('./'),
4530
src: path.resolve('./ClientApp'),
4631
baseUrl: '/'
47-
}),
48-
new webpack.optimize.CommonsChunkPlugin({
49-
name: ['aurelia-modules']
50-
}),
32+
})
5133
].concat(isDevBuild ? [] : [
5234
// Plugins that apply in production builds only
5335
new webpack.optimize.UglifyJsPlugin()
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
var isDevBuild = process.argv.indexOf('--env.prod') < 0;
2+
var path = require('path');
3+
var webpack = require('webpack');
4+
var ExtractTextPlugin = require('extract-text-webpack-plugin');
5+
var extractCSS = new ExtractTextPlugin('vendor.css');
6+
7+
module.exports = {
8+
resolve: {
9+
extensions: [ '.js' ]
10+
},
11+
module: {
12+
loaders: [
13+
{ test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, loader: 'url-loader?limit=100000' },
14+
{ test: /\.css(\?|$)/, loader: extractCSS.extract(['css']) }
15+
]
16+
},
17+
entry: {
18+
vendor: [
19+
'aurelia-event-aggregator',
20+
'aurelia-fetch-client',
21+
'aurelia-framework',
22+
'aurelia-history-browser',
23+
'aurelia-logging-console',
24+
'aurelia-pal-browser',
25+
'aurelia-polyfills',
26+
'aurelia-route-recognizer',
27+
'aurelia-router',
28+
'aurelia-templating-binding',
29+
'aurelia-templating-resources',
30+
'aurelia-templating-router',
31+
'bootstrap',
32+
'bootstrap/dist/css/bootstrap.css',
33+
'jquery'
34+
],
35+
},
36+
output: {
37+
path: path.join(__dirname, 'wwwroot', 'dist'),
38+
filename: '[name].js',
39+
library: '[name]_[hash]',
40+
},
41+
plugins: [
42+
extractCSS,
43+
new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable)
44+
new webpack.DllPlugin({
45+
path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),
46+
name: '[name]_[hash]'
47+
})
48+
].concat(isDevBuild ? [] : [
49+
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
50+
])
51+
};

0 commit comments

Comments
 (0)