Skip to content

Commit

Permalink
Merge branch 'release/0.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
DominusKelvin committed Dec 22, 2023
2 parents b8fcfa7 + b178b54 commit ee952b6
Show file tree
Hide file tree
Showing 11 changed files with 3,726 additions and 0 deletions.
1 change: 1 addition & 0 deletions .commitlintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] }
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: DominusKelvin
22 changes: 22 additions & 0 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Prettier

on: [push, pull_request]

jobs:
prettier:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Run npm ci
run: npm ci

- name: Run Prettier
run: npx prettier --config ./.prettierrc.js --write .
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit ${1}
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
5 changes: 5 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
semi: false,
singleQuote: true,
trailingComma: 'none'
}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Shipwright
Shipwright is the modern asset pipeline for Sails.

## License

The [Sails framework](http://sailsjs.com) is free and open-source under the [MIT License](http://sailsjs.com/license).
81 changes: 81 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* shipwright hook
*
* @description :: A hook definition. Extends Sails by adding shadow routes, implicit actions, and/or initialization logic.
* @docs :: https://sailsjs.com/docs/concepts/extending-sails/hooks
*/

const path = require('path')
const { defineConfig, mergeRsbuildConfig } = require('@rsbuild/core')
module.exports = function defineShipwrightHook(sails) {
return {
/**
* Runs when this Sails app loads/lifts.
*/
initialize: async function () {
const appPath = sails.config.appPath

const defaultConfigs = defineConfig({
source: {
entry: {
app: path.resolve(appPath, 'assets', 'js', 'app.js')
},
alias: {
'@': path.resolve(appPath, 'assets', 'js'),
'~': path.resolve(appPath, 'assets')
}
},
output: {
disableFilenameHash: true,
distPath: {
root: '.tmp/public',
css: 'css',
js: 'js',
font: 'fonts',
image: 'images',
html: '/'
},
copy: [
{
from: path.resolve(appPath, 'assets', 'images'),
to: path.resolve(appPath, '.tmp', 'public', 'images')
},
{
from: path.resolve(appPath, 'assets', 'fonts'),
to: path.resolve(appPath, '.tmp', 'public', 'fonts')
},
{
context: path.resolve(appPath, 'assets'),
from: '**/*.html',
to: path.resolve(appPath, '.tmp', 'public'),
noErrorOnMissing: true
}
]
},
tools: {
htmlPlugin: false
},
performance: {
chunkSplit: {
strategy: 'all-in-one'
}
}
})
const config = mergeRsbuildConfig(
defaultConfigs,
sails.config.shipwright.build
)
const { createRsbuild } = require('@rsbuild/core')
try {
const rsbuild = await createRsbuild({ rsbuildConfig: config })
if (process.env.NODE_ENV == 'production') {
rsbuild.build()
} else {
rsbuild.build({ mode: 'development', watch: true })
}
} catch (error) {
sails.error(error)
}
}
}
}
Loading

0 comments on commit ee952b6

Please sign in to comment.