sails-hook-shipwright 1.0.0 → 1.0.2

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.
Files changed (2) hide show
  1. package/index.js +18 -9
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -18,6 +18,7 @@ const { createLogger, randomQuote } = require('./lib/log')
18
18
 
19
19
  module.exports = function defineShipwrightHook(sails) {
20
20
  let log
21
+ let tagGenerators
21
22
 
22
23
  return {
23
24
  defaults: {
@@ -43,8 +44,25 @@ module.exports = function defineShipwrightHook(sails) {
43
44
  config.js.entry = detectJsEntry(appPath, config.js.entry)
44
45
 
45
46
  validatePlugins({ appPath, stylesEntry: config.styles.entry, log })
47
+
48
+ // Create tag generators early so other hooks can use them
49
+ tagGenerators = createTagGenerators(appPath, {
50
+ jsInject: config.js.inject,
51
+ cssInject: config.styles.inject
52
+ })
53
+
54
+ // Register view locals
55
+ sails.config.views = sails.config.views || {}
56
+ sails.config.views.locals = {
57
+ ...sails.config.views.locals,
58
+ shipwright: tagGenerators
59
+ }
46
60
  },
47
61
 
62
+ // Expose tag generators on hook for other hooks to use
63
+ scripts: () => tagGenerators?.scripts() || '',
64
+ styles: () => tagGenerators?.styles() || '',
65
+
48
66
  /**
49
67
  * Initialize hook.
50
68
  * Starts Rsbuild build (production) or dev server (development).
@@ -151,15 +169,6 @@ module.exports = function defineShipwrightHook(sails) {
151
169
  log.silly('Dropping anchor... goodbye!')
152
170
  })
153
171
  }
154
-
155
- // Register view locals (merge, don't overwrite)
156
- sails.config.views.locals = {
157
- ...sails.config.views.locals,
158
- shipwright: createTagGenerators(appPath, {
159
- jsInject: config.js.inject,
160
- cssInject: config.styles.inject
161
- })
162
- }
163
172
  } catch (error) {
164
173
  log.error('Build failed')
165
174
  log.error(error)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sails-hook-shipwright",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "The modern asset pipeline for Sails",
5
5
  "main": "index.js",
6
6
  "scripts": {