This repository was archived by the owner on Nov 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatamic.js
45 lines (35 loc) · 1.55 KB
/
statamic.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
// @see https://github.com/developit/dlv
const delve = require('dlv');
const setIfUnknown = require('../helpers/setIfUnknown');
module.exports = (options = {}, webpackOptions = {}) => {
// Some settings need to be set as "user" settings,
// but only if the user did not provide them
setIfUnknown(webpackOptions, 'css.extract.filename', '[name].css');
setIfUnknown(webpackOptions, 'devServer.host', 'localhost');
setIfUnknown(webpackOptions, 'output.path', delve(options, 'assetsPath'));
setIfUnknown(webpackOptions, 'output.filename', '[name].js');
return {
output: {
// Only set public path on production. In development this will be
// set dynamically.
publicPath: options.mode !== 'production'
? null
: delve(options, 'publicPath'),
},
devServer: {
// By default assets should be written to disk as Statamic
// projects are served via vhost.
writeToDisk: true,
// Make sure HMR client always connects to localhost by default
public: 'localhost',
// Make sure connections from vhost are allowed to devServer
allowedHosts: [delve(options, 'vhost')],
// Usually we need to enable CORS since we use a vhost.
// @see https://webpack.js.org/configuration/dev-server/#devserverheaders
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': '*',
},
},
};
};