@maizzle/framework 4.6.0 → 4.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/commands/serve.js +12 -3
- package/src/generators/config.js +18 -5
package/package.json
CHANGED
package/src/commands/serve.js
CHANGED
|
@@ -149,9 +149,12 @@ const serve = async (env = 'local', config = {}) => {
|
|
|
149
149
|
|
|
150
150
|
// Watch for changes in config files
|
|
151
151
|
browsersync()
|
|
152
|
-
.watch('config
|
|
152
|
+
.watch('{maizzle.config*,config*}.{js,cjs}')
|
|
153
153
|
.on('change', async file => {
|
|
154
|
-
const
|
|
154
|
+
const fileName = path.parse(file).base
|
|
155
|
+
const match = fileName.match(/\.?config\.(.+?)\./)
|
|
156
|
+
|
|
157
|
+
const parsedEnv = match ? match[1] : env || 'local'
|
|
155
158
|
|
|
156
159
|
Config
|
|
157
160
|
.getMerged(parsedEnv)
|
|
@@ -180,7 +183,13 @@ const serve = async (env = 'local', config = {}) => {
|
|
|
180
183
|
},
|
|
181
184
|
tunnel: false,
|
|
182
185
|
ui: {port: 3001},
|
|
183
|
-
logFileChanges: false
|
|
186
|
+
logFileChanges: false,
|
|
187
|
+
watchOptions: {
|
|
188
|
+
awaitWriteFinish: {
|
|
189
|
+
stabilityThreshold: 150,
|
|
190
|
+
pollInterval: 25
|
|
191
|
+
}
|
|
192
|
+
}
|
|
184
193
|
},
|
|
185
194
|
get(config, 'build.browsersync', {})
|
|
186
195
|
), () => {})
|
package/src/generators/config.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
2
|
const {merge, requireUncached} = require('../utils/helpers')
|
|
3
3
|
|
|
4
|
+
const baseConfigFileNames = [
|
|
5
|
+
'./maizzle.config.js',
|
|
6
|
+
'./maizzle.config.cjs',
|
|
7
|
+
'./maizzle.config.local.js',
|
|
8
|
+
'./maizzle.config.local.cjs',
|
|
9
|
+
'./config.js',
|
|
10
|
+
'./config.cjs',
|
|
11
|
+
'./config.local.js',
|
|
12
|
+
'./config.local.cjs'
|
|
13
|
+
]
|
|
14
|
+
|
|
4
15
|
module.exports = {
|
|
5
16
|
getMerged: async (env = 'local') => {
|
|
6
17
|
if (typeof env !== 'string') {
|
|
@@ -10,17 +21,19 @@ module.exports = {
|
|
|
10
21
|
let baseConfig = {env}
|
|
11
22
|
let envConfig = {env}
|
|
12
23
|
|
|
13
|
-
const cwd =
|
|
24
|
+
const cwd = ['maizzle-ci', 'test'].includes(env) ? './test/stubs/config' : process.cwd()
|
|
14
25
|
|
|
15
|
-
for (const module of
|
|
26
|
+
for (const module of baseConfigFileNames) {
|
|
16
27
|
try {
|
|
17
28
|
baseConfig = merge(baseConfig, requireUncached(path.resolve(cwd, module)))
|
|
18
29
|
} catch {}
|
|
19
30
|
}
|
|
20
31
|
|
|
21
|
-
if (
|
|
32
|
+
if (env !== 'local') {
|
|
22
33
|
let loaded = false
|
|
23
|
-
|
|
34
|
+
const modulesToTry = [`./maizzle.config.${env}.js`, `./maizzle.config.${env}.cjs`, `./config.${env}.js`, `./config.${env}.cjs`]
|
|
35
|
+
|
|
36
|
+
for (const module of modulesToTry) {
|
|
24
37
|
try {
|
|
25
38
|
envConfig = merge(envConfig, requireUncached(path.resolve(cwd, module)))
|
|
26
39
|
loaded = true
|
|
@@ -29,7 +42,7 @@ module.exports = {
|
|
|
29
42
|
}
|
|
30
43
|
|
|
31
44
|
if (!loaded) {
|
|
32
|
-
throw new Error(`
|
|
45
|
+
throw new Error(`Failed to load config file for \`${env}\` environment, do you have one of these files in your project root?\n\n${modulesToTry.join('\n')}`)
|
|
33
46
|
}
|
|
34
47
|
}
|
|
35
48
|
|