-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.babel.js
99 lines (89 loc) · 2.41 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
import webpack from 'webpack'
import path from 'path'
import fs from 'fs'
import dotenv from 'dotenv' // https://github.com/motdotla/dotenv
import { generateConfig, stripMetadata } from '@easy-webpack/core'
import envDev from '@easy-webpack/config-env-development'
import babel from '@easy-webpack/config-babel'
dotenv.config()
process.env.BABEL_ENV = `webpack`
const ENV = process.env.NODE_ENV && process.env.NODE_ENV.toLowerCase() || (process.env.NODE_ENV = `development`)
const nodeModules = {}
fs.readdirSync(`node_modules`)
.filter(x => [`.bin`].indexOf(x) === -1)
.forEach(mod => nodeModules[mod] = `commonjs ` + mod)
// Main Webpack Configuration
const config = generateConfig(
{
entry: {
'server': `./src/server`
},
target: `node`,
output: {
path: path.resolve(`dist`),
filename: `server.js`
},
externals: nodeModules
},
ENV === `test` ? envDev({devtool: `inline-source-map`}) : envDev(),
babel(),
ENV === `production` ? {
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
conditionals: true,
unused: true,
comparisons: true,
sequences: true,
dead_code: true,
evaluate: true,
join_vars: true,
if_return: true
},
output: {
comments: false
}
})
]} : { plugins: [
new webpack.optimize.UglifyJsPlugin({
beautify: true,
mangle: false,
dead_code: true,
unused: true,
compress: {
keep_fnames: true,
drop_debugger: false,
dead_code: true,
unused: true,
warnings: false
},
comments: true
})
]},
ENV === `development` ? { performance: { hints: false } } : {},
{
module: {
rules: [
{ test: /\.(graphql|gql)$/, exclude: /node_modules/, loader: `graphql-tag/loader` },
{ test: /\src\/images$/, loader: `ignore-loader` }
]
},
plugins: [
new webpack.EnvironmentPlugin([
`HTTP`,
`HTTPS`,
`LOGLEVEL`,
`DB_HOST`,
`DB_USERNAME`,
`DB_PASSWORD`,
`DB_NAME`,
`LOGGLY_TOKEN`,
`LOGGLY_SUBDOMAIN`,
`DD_API_KEY`
]),
new webpack.BannerPlugin({ banner: `require("source-map-support").install();`, raw: true, entryOnly: false })
]
}
)
module.exports = stripMetadata(config)