-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.babel.js
More file actions
94 lines (89 loc) · 2.22 KB
/
webpack.config.babel.js
File metadata and controls
94 lines (89 loc) · 2.22 KB
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
import path from 'path'
import webpack from 'webpack'
import HtmlWebpackPlugin from 'html-webpack-plugin'
const dev = process.env.NODE_ENV !== 'production'
const targetWeb = process.env.TARGET !== 'node'
const config = {
output: {
path: path.resolve(__dirname, 'build'),
},
module: {
rules: [
{
test: /.js$/,
include: path.resolve(__dirname, 'src'),
loader: 'babel-loader',
options: {
presets: ['env', 'react'],
plugins: ['transform-object-rest-spread']
},
},
{
test: /.hbs$/,
include: path.resolve(__dirname, 'src'),
loader: 'handlebars-loader',
options: {
helperDirs: [`${__dirname}/src/util/helpers`]
}
},
{
test: /.m4a$/,
include: path.resolve(__dirname, 'src'),
loader: 'file-loader',
query: {
name: '[name][hash].[ext]'
}
}
]
},
resolve: {
extensions: ['.js'],
alias: {
'@util': `${__dirname}/src/util`,
'@items': `${__dirname}/src/items`,
'@actions': `${__dirname}/src/actions`,
'@sectors': `${__dirname}/src/sectors`,
'@describe': `${__dirname}/src/describe`,
'@useables': `${__dirname}/src/useables`,
'@inputtables': `${__dirname}/src/inputtables`
}
},
devtool: dev ? 'source-map' : ''
}
const webConfig = {
...config,
target: 'web',
entry: './src/index.js',
output: {
...config.output,
filename: '[name].[chunkhash].js',
publicPath: './',
},
devServer: {
// makes app available at the dev server root (http://localhost:8080/)
contentBase: path.join(__dirname, 'build'),
},
plugins: [
new HtmlWebpackPlugin({
title: 'technoglyph',
template: 'template.ejs',
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: module => (
module.context && module.context.indexOf('node_modules') !== -1
)
}),
new webpack.optimize.CommonsChunkPlugin({ name: 'manifest' })
]
}
const nodeConfig = {
...config,
target: 'node',
entry: './src/node-runner.js',
output: {
...config.output,
filename: 'test.js',
}
}
export default targetWeb ? webConfig : nodeConfig