@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maizzle/framework",
3
- "version": "4.6.0",
3
+ "version": "4.6.1",
4
4
  "description": "Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.",
5
5
  "license": "MIT",
6
6
  "main": "src/index.js",
@@ -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*.js')
152
+ .watch('{maizzle.config*,config*}.{js,cjs}')
153
153
  .on('change', async file => {
154
- const parsedEnv = path.parse(file).name.split('.')[1] || 'local'
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
  ), () => {})
@@ -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 = env === 'maizzle-ci' ? './test/stubs/config' : process.cwd()
24
+ const cwd = ['maizzle-ci', 'test'].includes(env) ? './test/stubs/config' : process.cwd()
14
25
 
15
- for (const module of ['./config', './config.cjs', './config.local', './config.local.cjs']) {
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 (typeof env === 'string' && env !== 'local') {
32
+ if (env !== 'local') {
22
33
  let loaded = false
23
- for (const module of [`./config.${env}`, `./config.${env}.cjs`]) {
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(`could not load config.${env}.js`)
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