Skip to content

Commit

Permalink
Merge branch 'release/0.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
DominusKelvin committed Jul 31, 2024
2 parents 5dbb798 + 5576bd6 commit b617e18
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
46 changes: 25 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@ module.exports = function defineShipwrightHook(sails) {
const files = data.allFiles
return files
}
function generateScripts() {
const manifestFiles = getManifestFiles()
let scripts = []
manifestFiles.forEach((file) => {
if (file.endsWith('.js')) {
scripts.push(`<script type="text/javascript" src="${file}"></script>`)
}
})
return scripts.join('\n')
}

function generateStyles() {
const manifestFiles = getManifestFiles()
let styles = []
manifestFiles.forEach((file) => {
if (file.endsWith('.css')) {
styles.push(`<link rel="stylesheet" href="${file}">`)
}
})
return styles.join('\n')
}
return {
generateScripts: function generateScripts() {
const manifestFiles = getManifestFiles()
let scripts = []
manifestFiles.forEach((file) => {
if (file.endsWith('.js')) {
scripts.push(`<script type="text/javascript" src="${file}"></script>`)
}
})
return scripts.join('\n')
},
generateStyles: function generateStyles() {
const manifestFiles = getManifestFiles()
let styles = []
manifestFiles.forEach((file) => {
if (file.endsWith('.css')) {
styles.push(`<link rel="stylesheet" href="${file}">`)
}
})
return styles.join('\n')
},
defaults: {
shipwright: {
build: {}
Expand All @@ -50,6 +50,7 @@ module.exports = function defineShipwrightHook(sails) {
* Runs when this Sails app loads/lifts.
*/
initialize: async function () {
const hook = this
const appPath = sails.config.appPath
const defaultConfigs = defineConfig({
source: {
Expand Down Expand Up @@ -139,7 +140,10 @@ module.exports = function defineShipwrightHook(sails) {
sails.after('lifted', () => {})
}
sails.config.views.locals = {
shipwright: { scripts: generateScripts, styles: generateStyles }
shipwright: {
scripts: hook.generateScripts,
styles: hook.generateStyles
}
}
} catch (error) {
sails.log.error(error)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sails-hook-shipwright",
"version": "0.2.1",
"version": "0.2.2",
"description": "The modern asset pipeline for Sails",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit b617e18

Please sign in to comment.