@maizzle/framework 4.4.0-beta.6 → 4.4.0-beta.7

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.4.0-beta.6",
3
+ "version": "4.4.0-beta.7",
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",
@@ -9,6 +9,10 @@ const renderToString = require('../functions/render')
9
9
  const {get, merge, isObject} = require('lodash')
10
10
  const {clearConsole} = require('../utils/helpers')
11
11
 
12
+ /**
13
+ * Initialize Browsersync on-demand
14
+ * https://github.com/maizzle/framework/issues/605
15
+ */
12
16
  const browsersync = () => {
13
17
  if (!global.cachedBrowserSync) {
14
18
  const bs = require('browser-sync')
@@ -18,16 +22,17 @@ const browsersync = () => {
18
22
  return global.cachedBrowserSync
19
23
  }
20
24
 
25
+ const getConfig = async (env = 'local', config = {}) => merge(
26
+ config,
27
+ await Config.getMerged(env)
28
+ )
29
+
21
30
  const serve = async (env = 'local', config = {}) => {
22
- config = merge(
23
- config,
24
- await Config.getMerged(env),
25
- {
26
- build: {
27
- command: 'serve'
28
- }
31
+ config = await getConfig(env, merge(config, {
32
+ build: {
33
+ command: 'serve'
29
34
  }
30
- )
35
+ }))
31
36
 
32
37
  const spinner = ora()
33
38
 
@@ -43,14 +48,17 @@ const serve = async (env = 'local', config = {}) => {
43
48
  'src/**',
44
49
  ...new Set(get(config, 'build.browsersync.watch', []))
45
50
  ]
51
+
46
52
  if (typeof tailwindConfig === 'string') {
47
- globalPaths.push(tailwindConfig);
53
+ globalPaths.push(tailwindConfig)
48
54
  }
49
55
 
50
56
  // Watch for Template file changes
51
57
  browsersync()
52
58
  .watch(templatePaths)
53
59
  .on('change', async file => {
60
+ config = await getConfig(env, config)
61
+
54
62
  if (config.events && typeof config.events.beforeCreate === 'function') {
55
63
  await config.events.beforeCreate(config)
56
64
  }