-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
77 lines (76 loc) · 3.08 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// The plugin that loads your source code in Aurelia.
var AureliaWebPackPlugin = require('aurelia-webpack-plugin');
// This is a node tool to resolve paths.
var path = require('path');
// We need this to use the CommonsChunkPlugin.
var webpack = require('webpack');
// The plugin that adds the script tags to our index.html
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
// Our app's entry point, this is set automatically by aurelia-webpack-plugin
// using the files in the "src" folder that we're still going to create.
// The app knows which of the files is our entry point because of the "aurelia-bootstrapper-webpack"
// who reads the entry point from the aurelia-app="main" in our index.html.
'app': [],
//These are all the aurelia libraries, they will be bundled separately from our app's main code.
//I tried to bundle everything together, with no success.
'aurelia': [
'aurelia-bootstrapper-webpack',
'aurelia-polyfills',
'aurelia-pal',
'aurelia-pal-browser',
'aurelia-binding',
'aurelia-dependency-injection',
'aurelia-event-aggregator',
'aurelia-framework',
'aurelia-history',
'aurelia-history-browser',
'aurelia-loader',
'aurelia-loader-webpack',
'aurelia-logging',
'aurelia-logging-console',
'aurelia-metadata',
'aurelia-path',
'aurelia-route-recognizer',
'aurelia-router',
'aurelia-task-queue',
'aurelia-templating',
'aurelia-templating-binding',
'aurelia-templating-router',
'aurelia-templating-resources'
]
},
output: {
//This is the folder where our packed app will be after we run webpack.
path: './build',
filename: 'scripts/[name].bundle.js',
sourceMapFilename: 'scripts/[name].bundle.js.map'
},
module: {
loaders: [
//This loader runs babel for every js file so the files are transpiled to ES5 javascript.
{ test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" },
//This loader reads our html templates that are referenced and bundles them with our javascript.
{ test: /\.html$/, loader:'html', exclude: path.resolve('src/index.html') }
]
},
plugins: [
//The Aurelia Plugin.
new AureliaWebPackPlugin(),
// This is what will create a separate bundle for the libs under 'aurelia'
// in our entry section.
new webpack.optimize.CommonsChunkPlugin({ name: ['aurelia']}),
// This plugin will add our bundles to the html file and copy it
// to the build folder.
new HtmlWebpackPlugin({
template: 'index.html',
chunksSortMode: 'dependency'
}),
],
// This is not necessary, it just changes the default port the
// webpack-dev-server uses from 3000 to whatever you set.
devServer: {
port: 3333
}
};