This repository has been archived by the owner on Feb 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathwebpack.config.js
64 lines (60 loc) · 1.75 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
/* eslint no-console: 0 */
const path = require('path')
const assert = require('assert')
const InlineEnviromentVariablesPlugin = require('inline-environment-variables-webpack-plugin')
const prefix = process.env.BUILD_PREFIX || 'www'
const INLINED_ENVIRONMENT_VARIABLES = ['BACKEND_URL', 'TRACKING_URL', 'ROUTING_URL']
INLINED_ENVIRONMENT_VARIABLES.forEach(function (key) {
assert(process.env[key], 'process.env.' + key + ' must be set')
})
module.exports = function (env) {
env = env || {}
return [
// Javascript Config
{
devtool: 'source-map',
module: {
rules: [
// Enable ES6 goodness
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
// Allow HTML imports
{
test: /\.html$/,
loader: 'html-loader',
options: { attrs: false }, // disable img:src loading
},
// Allow JSON imports
{
test: /\.json$/,
loader: 'json-loader',
},
// Fix for libraries that require globals
{
test: require.resolve(
'multiple-date-picker/dist/multipleDatePicker'
),
loader: 'imports-loader?moment',
},
],
},
entry: ['babel-polyfill', path.resolve('beeline/main.js')],
output: {
path: path.resolve(prefix, 'lib/beeline'),
filename: 'bundle.js',
pathinfo: !env.production,
},
plugins: [
new InlineEnviromentVariablesPlugin(INLINED_ENVIRONMENT_VARIABLES),
],
externals: {
// Ionic's bundle already includes angular,
// so we don't have to load it again
angular: 'angular',
},
},
]
}