-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.babel.js
executable file
·125 lines (113 loc) · 4.1 KB
/
webpack.config.babel.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
/**
* To learn more about how to use Easy Webpack
* Take a look at the README here: https://github.com/easy-webpack/core
**/
import { generateConfig, get, stripMetadata, EasyWebpackConfig } from '@easy-webpack/core'
import path from 'path'
import envProd from '@easy-webpack/config-env-production'
import envDev from '@easy-webpack/config-env-development'
import aurelia from '@easy-webpack/config-aurelia'
import babel from '@easy-webpack/config-babel'
import html from '@easy-webpack/config-html'
import css from '@easy-webpack/config-css'
import fontAndImages from '@easy-webpack/config-fonts-and-images'
import globalBluebird from '@easy-webpack/config-global-bluebird'
import globalJquery from '@easy-webpack/config-global-jquery'
import globalRegenerator from '@easy-webpack/config-global-regenerator'
import generateIndexHtml from '@easy-webpack/config-generate-index-html'
import commonChunksOptimize from '@easy-webpack/config-common-chunks-simple'
import copyFiles from '@easy-webpack/config-copy-files'
import uglify from '@easy-webpack/config-uglify'
import generateCoverage from '@easy-webpack/config-test-coverage-istanbul'
process.env.BABEL_ENV = 'webpack'
const ENV = process.env.NODE_ENV && process.env.NODE_ENV.toLowerCase() || (process.env.NODE_ENV = 'development')
// 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-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'
],
vendor: [
'whatwg-fetch',
]
}
/**
* Main Webpack Configuration
*/
let config = generateConfig(
{
entry: {
'app': ['./src/main' /* this is filled by the aurelia-webpack-plugin */],
'aurelia-bootstrap': coreBundles.bootstrap,
'aurelia': coreBundles.aurelia.filter(pkg => coreBundles.bootstrap.indexOf(pkg) === -1),
// 'vendor': coreBundles.vendor,
},
output: {
path: outDir
}
},
/**
* Don't be afraid, you can put bits of standard Webpack configuration here
* (or at the end, after the last parameter, so it won't get overwritten by the presets)
* Because that's all easy-webpack configs are - snippets of premade, maintained configuration parts!
*
* For Webpack docs, see: https://webpack.js.org/configuration/
*/
ENV === 'test' || ENV === 'development' ?
envDev(ENV !== 'test' ? {} : {devtool: 'inline-source-map'}) :
envProd({ /* devtool: '...' */ }),
aurelia({root: rootDir, src: srcDir, title: title, baseUrl: baseUrl}),
babel({ options: { /* uses settings from .babelrc */ } }),
html(),
css({ filename: 'styles.css', allChunks: true, sourceMap: false }),
fontAndImages(),
globalBluebird(),
globalJquery(),
globalRegenerator(),
generateIndexHtml({minify: ENV === 'production'}),
...(ENV === 'production' || ENV === 'development' ? [
commonChunksOptimize({appChunkName: 'app', firstChunk: 'aurelia-bootstrap'}),
copyFiles({patterns: [{ from: 'favicon.ico', to: 'favicon.ico' }]})
] : [
/* ENV === 'test' */
generateCoverage({ options: { 'force-sourcemap': true, esModules: true }})
]),
ENV === 'production' ?
uglify({debug: false, mangle: { except: ['cb', '__webpack_require__'] }}) : {}
)
module.exports = stripMetadata(config)