-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
165 lines (136 loc) · 4.86 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
"use strict";
/**
* To learn more about how to use Easy Webpack
* Take a look at the README here: https://github.com/easy-webpack/core
**/
const easyWebpack = require('@easy-webpack/core');
const generateConfig = easyWebpack.default;
const get = easyWebpack.get;
const path = require('path');
const ENV = process.env.NODE_ENV && process.env.NODE_ENV.toLowerCase() || 'development';
let config;
// basic configuration:
const title = 'Aurelia Navigation Skeleton';
const baseUrl = '/';
const rootDir = path.resolve();
const srcDir = path.resolve('src');
const outDir = path.resolve('dist');
const coreBundles = {
bootstrap: [
'aurelia-bootstrapper-webpack',
'aurelia-polyfills',
'aurelia-pal',
'aurelia-pal-browser',
'regenerator-runtime',
'bluebird'
],
// these will be included in the 'aurelia' bundle (except for the above bootstrap packages)
aurelia: [
'aurelia-api',
'aurelia-bootstrapper-webpack',
'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-pal',
'aurelia-pal-browser',
'aurelia-path',
'aurelia-polyfills',
'aurelia-route-recognizer',
'aurelia-router',
'aurelia-task-queue',
'aurelia-templating',
'aurelia-templating-binding',
'aurelia-templating-router',
'aurelia-templating-resources'
]
}
const baseConfig = {
entry: {
'app': [/* this is filled by the aurelia-webpack-plugin */],
'aurelia-bootstrap': coreBundles.bootstrap,
'aurelia': coreBundles.aurelia.filter(pkg => coreBundles.bootstrap.indexOf(pkg) === -1)
},
output: {
path: outDir,
}
}
// advanced configuration:
switch (ENV) {
case 'production':
config = generateConfig(
baseConfig,
require('@easy-webpack/config-env-production')
({compress: true}),
require('@easy-webpack/config-aurelia')
({root: rootDir, src: srcDir, title: title, baseUrl: baseUrl}),
require('@easy-webpack/config-babel')(),
require('@easy-webpack/config-html')(),
require('@easy-webpack/config-css')
({ filename: 'styles.css', allChunks: true, sourceMap: false }),
require('@easy-webpack/config-fonts-and-images')(),
require('@easy-webpack/config-global-bluebird')(),
require('@easy-webpack/config-global-jquery')(),
require('@easy-webpack/config-global-regenerator')(),
require('@easy-webpack/config-generate-index-html')
({minify: true}),
require('@easy-webpack/config-copy-files')
({patterns: [{ from: 'favicon.ico', to: 'favicon.ico' }]}),
require('@easy-webpack/config-common-chunks-simple')
({appChunkName: 'app', firstChunk: 'aurelia-bootstrap'}),
require('@easy-webpack/config-uglify')
({debug: false})
);
break;
case 'test':
config = generateConfig(
baseConfig,
require('@easy-webpack/config-env-development')
({devtool: 'inline-source-map'}),
require('@easy-webpack/config-aurelia')
({root: rootDir, src: srcDir, title: title, baseUrl: baseUrl}),
require('@easy-webpack/config-babel')(),
require('@easy-webpack/config-html')(),
require('@easy-webpack/config-css')
({ filename: 'styles.css', allChunks: true, sourceMap: false }),
require('@easy-webpack/config-fonts-and-images')(),
require('@easy-webpack/config-global-bluebird')(),
require('@easy-webpack/config-global-jquery')(),
require('@easy-webpack/config-global-regenerator')(),
require('@easy-webpack/config-generate-index-html')(),
require('@easy-webpack/config-test-coverage-istanbul')()
);
break;
default:
case 'development':
process.env.NODE_ENV = 'development';
config = generateConfig(
baseConfig,
require('@easy-webpack/config-env-development')(),
require('@easy-webpack/config-aurelia')
({root: rootDir, src: srcDir, title: title, baseUrl: baseUrl}),
require('@easy-webpack/config-babel')(),
require('@easy-webpack/config-html')(),
require('@easy-webpack/config-css')
({ filename: 'styles.css', allChunks: true, sourceMap: false }),
require('@easy-webpack/config-fonts-and-images')(),
require('@easy-webpack/config-global-bluebird')(),
require('@easy-webpack/config-global-jquery')(),
require('@easy-webpack/config-global-regenerator')(),
require('@easy-webpack/config-generate-index-html')
({minify: false}),
require('@easy-webpack/config-copy-files')
({patterns: [{ from: 'favicon.ico', to: 'favicon.ico' }]}),
require('@easy-webpack/config-common-chunks-simple')
({appChunkName: 'app', firstChunk: 'aurelia-bootstrap'})
);
break;
}
module.exports = config;