This repository has been archived by the owner on May 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
241 lines (228 loc) · 8.17 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
const { config } = require("@gladeye/bento");
module.exports = config({
/**
* ------------------------------------------------------------------------
* Environment
* ------------------------------------------------------------------------
* "value": The environment value that should be used to determine
* various aspects of webpack config, eg `devtool` value
*
*/
env: {
value: process.env.NODE_ENV || "development",
isProduction: process.env.NODE_ENV === "production",
isDevServer: process.argv[1].indexOf("webpack-dev-server") >= 0
},
/**
* ------------------------------------------------------------------------
* Paths
* ------------------------------------------------------------------------
* "root": The base directory, an absolute path, that will be used
* to resolved all other relative paths in here.
*
* "input": The base directory for webpack to looking for resolving
* entry points and loaders from configuration. It's relative
* to `paths.root` [1]
*
* "output": The output directory. It's relative to `paths.root` [2]
*
* "public": The public URL of the output directory when referenced
* in a browser. [3]
*
* [1] @see https://webpack.js.org/configuration/entry-context/#context
* [2] @see https://webpack.js.org/configuration/output/#output-path
* [3] @see https://webpack.js.org/configuration/output/#output-publicpath
*
*/
paths: {
root: process.cwd(),
input: "./public/content/themes/sage/resources/assets/",
output: "./public/content/themes/sage/resources/assets/dist/",
public: "/content/themes/sage/resources/assets/dist/"
},
/**
* ------------------------------------------------------------------------
* Entry
* ------------------------------------------------------------------------
* "main": The point or points to enter the application.
* Note: vendor static css files can be added here instead of
* using standard `import` to improve HMR reload speed. [1]
*
* [1] @see https://webpack.js.org/configuration/entry-context/#context
*
*/
entry: {
main: [
// "normalize.css/normalize.css"
"./scripts/main.js"
]
},
/**
* ------------------------------------------------------------------------
* Resolve
* ------------------------------------------------------------------------
* Webpack's `resolve` options can be defined here. [1]
*
* By default "~" is resolved to `scripts` folder, make it easier to
* import modules within there. [2]
*
* [1] @see https://webpack.js.org/configuration/resolve/
* [2] @see https://webpack.js.org/configuration/resolve/#resolve-alias
*
*/
resolve: {
alias: {
"~": "@{paths.input}/scripts"
}
},
/**
* ------------------------------------------------------------------------
* Caching
* ------------------------------------------------------------------------
* "hash": Hash length that will append to output files for
* long term caching. [1]
*
* [1] @see https://webpack.js.org/guides/caching/#the-problem
*
*/
caching: {
hash: ".[hash:8]",
},
/**
* ------------------------------------------------------------------------
* Additional options
* ------------------------------------------------------------------------
* sourceMap: Enable / disable source map
*
*/
enabled: {
sourceMap: true
},
/**
* ------------------------------------------------------------------------
* Browserslist
* ------------------------------------------------------------------------
* "browsers": Define stack of supported browsers that will use for
* PostCSS `autoprefixer` and `babel-preset-env` [1]
*
* [1] @see https://github.com/ai/browserslist#queries
*
*/
browserslist: {
browsers: [
"last 1 version"
]
},
/**
* ------------------------------------------------------------------------
* Babel
* ------------------------------------------------------------------------
* `babel-loader` options can be defined here. [1]
*
* By default, `babel-loader` is configured with 2 presets,
* `babel-preset-env` and `babel-preset-stage-2` [2]
*
* [1] @see https://github.com/babel/babel-loader
* [2] @see https://github.com/babel/babel-preset-env
*
*/
babel: {
presets: [
[
"env",
{
targets: {
browsers: "@{browserslist.browsers}"
},
loose: true,
modules: false,
useBuiltIns: true
}
],
"stage-2"
]
},
/**
* ------------------------------------------------------------------------
* Browsersync
* ------------------------------------------------------------------------
* `browsersyncs` options can be defined here, notes that `port` and
* `proxy` will be ignored
*
* @see https://www.browsersync.io/docs/options#option-files
*/
browsersync: {
open: true,
ghostMode: false,
watchOptions: {
ignoreInitial: true,
ignored: "*.txt",
cwd: "@{paths.root}/public/content/themes/sage"
},
files: [
"{app,resources/views}/**/*.php"
]
},
/**
* ------------------------------------------------------------------------
* Files
* ------------------------------------------------------------------------
* "copy": Copy files that match the pattern to the output folder.
* Note: glob path is relative to `paths.input`
*
*/
files: {
copy: "+(images|media)/**/*"
},
/**
* ------------------------------------------------------------------------
* Back-end Server
* ------------------------------------------------------------------------
* "proxy": Map of endpoints that should be proxied to a back-end
* server. Note: currently, only a single value "/" is
* supported.
*
*/
server: {
proxy: {
"/": {
target: "http://localhost:8080",
changeOrigin: true,
autoRewrite: true
}
}
},
/**
* ------------------------------------------------------------------------
* Blocks
* ------------------------------------------------------------------------
* Webpack config are constructed by waterfall-ling down to each one of
* these blocks, thus order matters. Feel free to add you own, list item
* must be a function which will receive `config, options, utils` as
* arguments. The `config` argument is an instance of `webpack-config`
*
* @see https://fitbit.github.io/webpack-config/
*
* "list": List of blocks that will construct webpack config. Check
* existing blocks for usage.
* Note: Block item can return a Promise
*
* "timeout": Wait time before throwing a timeout error if async block
* hasn't been resolved or rejected.
*
*/
blocks: {
timeout: 3000,
list: [
require("@gladeye/bento/config/blocks/ports"),
require("@gladeye/bento/config/blocks/name"),
require("@gladeye/bento/config/blocks/manifest"),
require("@gladeye/bento/config/blocks/base"),
require("@gladeye/bento/config/blocks/script"),
require("@gladeye/bento/config/blocks/style"),
require("@gladeye/bento/config/blocks/media"),
require("@gladeye/bento/config/blocks/plugins"),
require("@gladeye/bento/config/blocks/dev-server")
]
}
});