sails-hook-shipwright 1.0.1 → 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 +14 -5
  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: {
@@ -44,16 +45,24 @@ module.exports = function defineShipwrightHook(sails) {
44
45
 
45
46
  validatePlugins({ appPath, stylesEntry: config.styles.entry, log })
46
47
 
47
- // Register view locals early so other hooks/plugins can use them
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 || {}
48
56
  sails.config.views.locals = {
49
57
  ...sails.config.views.locals,
50
- shipwright: createTagGenerators(appPath, {
51
- jsInject: config.js.inject,
52
- cssInject: config.styles.inject
53
- })
58
+ shipwright: tagGenerators
54
59
  }
55
60
  },
56
61
 
62
+ // Expose tag generators on hook for other hooks to use
63
+ scripts: () => tagGenerators?.scripts() || '',
64
+ styles: () => tagGenerators?.styles() || '',
65
+
57
66
  /**
58
67
  * Initialize hook.
59
68
  * Starts Rsbuild build (production) or dev server (development).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sails-hook-shipwright",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "The modern asset pipeline for Sails",
5
5
  "main": "index.js",
6
6
  "scripts": {