coralite-scripts 0.28.2 → 0.28.4

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Coralite Development Environment Guide
1
+ # Coralite Scripts
2
2
 
3
- Welcome to **Coralite starter script**, a lightweight Static Site Generator (SSG) built for rapid development and clean output. This guide walks you through setting up your local development environment using the provided `coralite-scripts` package and configuration files.
3
+ Welcome to **Coralite Scripts**, a lightweight script toolset for building and serving Coralite applications. This guide walks you through setting up your local development environment using the provided `coralite-scripts` package and configuration files.
4
4
 
5
5
  ---
6
6
 
@@ -12,8 +12,8 @@ Coralite expects a standard folder layout:
12
12
  my-coralite-site/
13
13
  ├── src/
14
14
  │ ├── pages/ # Your page components (e.g., `about.html`, `index.html`)
15
- │ ├── scss/ # SCSS/Sass styles
16
- │ └── components/ # Reusable component files
15
+ │ ├── scss/ # SCSS/Sass/CSS styles
16
+ │ └── components/ # Reusable component files
17
17
  ├── public/ # Static assets (CSS, JS, images)
18
18
  ├── dist/ # Output directory for built site (auto-generated)
19
19
  ├── coralite.config.js # Configuration file
@@ -34,13 +34,26 @@ export default defineConfig({
34
34
  public: 'public',
35
35
  pages: 'src/pages',
36
36
  components: 'src/components',
37
- sass: {
37
+ styles: {
38
+ type: 'scss', // can be 'scss', 'sass', or 'css'
38
39
  input: 'src/scss'
39
- }
40
+ },
41
+ // Optional: copy static assets from other packages
42
+ assets: [
43
+ { pkg: 'some-package', path: 'dist/asset.js', dest: 'assets/asset.js' }
44
+ ],
45
+ // Optional: ignore processing elements with specific attributes
46
+ ignoreByAttribute: [
47
+ { name: 'data-ignore', value: 'true' }
48
+ ],
49
+ // Optional: skip rendering elements with specific attributes
50
+ skipRenderByAttribute: [
51
+ { name: 'data-skip', value: 'true' }
52
+ ]
40
53
  })
41
54
  ```
42
55
 
43
- > This tells Coralite where to find your source files, compile CSS from SCSS, and serve static assets.
56
+ > This tells Coralite where to find your source files, compile CSS from SCSS/Sass/CSS, and serve static assets. It also sets up advanced features like copying static assets or ignoring/skipping rendering of specific elements based on attributes.
44
57
 
45
58
  ---
46
59
 
@@ -48,10 +61,11 @@ export default defineConfig({
48
61
 
49
62
  Update your `package.json` scripts to include:
50
63
 
51
- ```json package.json
64
+ ```json
52
65
  {
53
66
  "scripts": {
54
- "start": "coralite-script"
67
+ "start": "coralite-scripts start",
68
+ "build": "coralite-scripts build"
55
69
  }
56
70
  }
57
71
  ```
@@ -62,7 +76,7 @@ Then start the dev server:
62
76
  npm run start
63
77
  ```
64
78
 
65
- > The server runs on `http://localhost:3000` by default.
79
+ > The server runs on `http://localhost:3000` by default.
66
80
 
67
81
  ---
68
82
 
@@ -72,7 +86,7 @@ Coralite provides real-time development workflows out of the box:
72
86
 
73
87
  | Feature | How It Works |
74
88
  |-------|-------------|
75
- | **Live Reload** | Automatically reloads browser when any `.html`, `.scss`, or `.sass` file changes. |
89
+ | **Live Reload** | Automatically reloads browser when any `.html`, `.scss`, `.sass`, or `.css` file changes. |
76
90
  | **Hot CSS Updates** | Sass/SCSS files are compiled instantly and injected into your page via Server-Sent Events (SSE). |
77
91
  | **File Watching** | Monitors `src/pages`, `src/scss`, `public`, and `src/components`. |
78
92
  | **Dev Logs** | Shows real-time build times, file changes, and status codes in terminal. |
@@ -82,8 +96,8 @@ Coralite provides real-time development workflows out of the box:
82
96
  ## How it works under the hood
83
97
 
84
98
  - **Routing**: `/` → `index.html`, `/about` → `about.html`
85
- - **HTML Compilation**: Pages are compiled with embedded live reload scripts.
86
- - **Sass Support**: `.scss`/`.sass` files are auto-compiled to CSS in `dist/css`.
99
+ - **HTML Compilation**: Pages are compiled with embedded live reload scripts during development.
100
+ - **Sass/CSS Support**: `.scss`, `.sass`, or `.css` files are auto-compiled to CSS in `dist/css`.
87
101
  - **Server-Sent Events (SSE)**: Used for real-time updates without full page refresh.
88
102
 
89
103
  > No extra tooling needed — everything is built-in!
@@ -109,6 +123,6 @@ Coralite provides real-time development workflows out of the box:
109
123
 
110
124
  ---
111
125
 
112
- > **Feedback?** Found a bug or want a feature? Open an issue!
126
+ > **Feedback?** Found a bug or want a feature? [Open an issue](https://codeberg.org/tjdavid/coralite/issues) on our Codeberg repository!
113
127
 
114
- Happy building with Coralite!
128
+ Happy building with Coralite!
package/bin/index.js CHANGED
@@ -64,7 +64,8 @@ if (mode === 'dev') {
64
64
  const coralite = new Coralite({
65
65
  components: config.components,
66
66
  pages: config.pages,
67
- plugins: config.plugins
67
+ plugins: config.plugins,
68
+ output: config.output
68
69
  })
69
70
  await coralite.initialise()
70
71
 
@@ -1,6 +1,3 @@
1
- /**
2
- * @import {CoraliteScriptConfig} from '../types/index.js'
3
- */
4
1
  /**
5
2
  * Defines the Coralite configuration for the project.
6
3
  *
@@ -22,9 +19,13 @@
22
19
  * server: {
23
20
  * port: 3000
24
21
  * },
25
- * sass: {
22
+ * styles: {
23
+ * type: 'scss',
26
24
  * input: './src/styles/main.scss'
27
- * }
25
+ * },
26
+ * assets: [
27
+ * { pkg: 'some-package', path: 'dist/asset.js', dest: 'assets/asset.js' }
28
+ * ]
28
29
  * })
29
30
  * ```
30
31
  */
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../libs/config.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,sCArBW,oBAAoB,GAClB,oBAAoB,CAmHhC;0CA7HsC,mBAAmB"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../libs/config.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,sCAzBW,oBAAoB,GAClB,oBAAoB,CA+HhC;0CA1IsC,mBAAmB"}
@@ -1,10 +1,28 @@
1
1
  declare const _default: {};
2
2
  export default _default;
3
+ export type CoraliteStaticAsset = {
4
+ /**
5
+ * - The package name to copy assets from.
6
+ */
7
+ pkg: string;
8
+ /**
9
+ * - The path to the asset within the package.
10
+ */
11
+ path: string;
12
+ /**
13
+ * - The destination path for the asset in the output directory.
14
+ */
15
+ dest: string;
16
+ };
3
17
  export type CoraliteScriptBaseConfig = {
4
18
  /**
5
19
  * - The path to the directory containing static assets.
6
20
  */
7
21
  public: string;
22
+ /**
23
+ * - Static assets to copy during build.
24
+ */
25
+ assets?: CoraliteStaticAsset[];
8
26
  /**
9
27
  * - Server configuration options.
10
28
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../types/index.js"],"names":[],"mappings":";;;;;;YAOc,MAAM;;;;aAEjB;QAA0B,IAAI,EAAnB,MAAM;KACjB;aACA;QAA2C,IAAI,EAApC,KAAK,GAAG,MAAM,GAAG,MAAM;QACR,KAAK,EAApB,MAAM;KACjB;;;;kBAAW,QAAQ,OAAO,CAAC;;;;iBAChB,OAAO,SAAS,EAAE,cAAc,EAAE;;;;WAClC,YAAY,GAAG,aAAa;;mCAI7B,wBAAwB,GAAG,cAAc;;;;;UAKxC,OAAO;;;;YACP,OAAO;;;;cACP,OAAO;;6BAxBK,MAAM;oCADC,gBAAgB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../types/index.js"],"names":[],"mappings":";;;;;;SAOc,MAAM;;;;UACN,MAAM;;;;UACN,MAAM;;;;;;YAKN,MAAM;;;;aACN,mBAAmB,EAAE;;;;aAEhC;QAA0B,IAAI,EAAnB,MAAM;KACjB;aACA;QAA2C,IAAI,EAApC,KAAK,GAAG,MAAM,GAAG,MAAM;QACR,KAAK,EAApB,MAAM;KACjB;;;;kBAAW,QAAQ,OAAO,CAAC;;;;iBAChB,OAAO,SAAS,EAAE,cAAc,EAAE;;;;WAClC,YAAY,GAAG,aAAa;;mCAI7B,wBAAwB,GAAG,cAAc;;;;;UAKxC,OAAO;;;;YACP,OAAO;;;;cACP,OAAO;;6BAhCK,MAAM;oCADC,gBAAgB"}
package/libs/config.js CHANGED
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @import {CoraliteScriptConfig} from '../types/index.js'
3
3
  */
4
+ import { staticAssetPlugin } from 'coralite/plugins'
4
5
 
5
6
  /**
6
7
  * Defines the Coralite configuration for the project.
@@ -23,9 +24,13 @@
23
24
  * server: {
24
25
  * port: 3000
25
26
  * },
26
- * sass: {
27
+ * styles: {
28
+ * type: 'scss',
27
29
  * input: './src/styles/main.scss'
28
- * }
30
+ * },
31
+ * assets: [
32
+ * { pkg: 'some-package', path: 'dist/asset.js', dest: 'assets/asset.js' }
33
+ * ]
29
34
  * })
30
35
  * ```
31
36
  */
@@ -123,5 +128,13 @@ export function defineConfig (options) {
123
128
  }
124
129
  }
125
130
 
131
+ if (options.assets) {
132
+ if (!Array.isArray(options.assets)) {
133
+ throw new Error('Configuration "assets" must be an array')
134
+ }
135
+ options.plugins = options.plugins || []
136
+ options.plugins.push(staticAssetPlugin(options.assets))
137
+ }
138
+
126
139
  return options
127
140
  }
package/libs/server.js CHANGED
@@ -39,7 +39,8 @@ async function server (config, options) {
39
39
  plugins: config.plugins,
40
40
  ignoreByAttribute: config.ignoreByAttribute,
41
41
  skipRenderByAttribute: config.skipRenderByAttribute,
42
- mode: 'development'
42
+ mode: 'development',
43
+ output: config.output
43
44
  })
44
45
  await coralite.initialise()
45
46
  displaySuccess('Coralite initialized successfully')
@@ -86,10 +87,17 @@ async function server (config, options) {
86
87
  next()
87
88
  })
88
89
 
90
+ const staticOptions = {
91
+ cacheControl: false,
92
+ setHeaders: (res, path) => {
93
+ if (path.endsWith('.wasm')) {
94
+ res.setHeader('Content-Type', 'application/wasm')
95
+ }
96
+ }
97
+ }
98
+
89
99
  // serve compiled components directory
90
- app.use(express.static(config.output, {
91
- cacheControl: false
92
- }))
100
+ app.use(express.static(config.output, staticOptions))
93
101
 
94
102
  // check if Sass is configured and add its input directory to watchPath for file changes.
95
103
  if (config.styles) {
@@ -139,9 +147,7 @@ async function server (config, options) {
139
147
  }
140
148
 
141
149
  app
142
- .use(express.static(config.public, {
143
- cacheControl: false
144
- }))
150
+ .use(express.static(config.public, staticOptions))
145
151
  .get('/_/rebuild', (req, res) => {
146
152
  // set headers for SSE
147
153
  res.writeHead(200, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coralite-scripts",
3
- "version": "0.28.2",
3
+ "version": "0.28.4",
4
4
  "description": "Configuration and scripts for Create Coralite.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -58,7 +58,7 @@
58
58
  "portfinder": "^1.0.38",
59
59
  "postcss": "^8.5.6",
60
60
  "sass": "^1.91.0",
61
- "coralite": "0.28.1"
61
+ "coralite": "0.28.2"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "premove dist && pnpm build-types",
package/types/index.js CHANGED
@@ -3,9 +3,17 @@
3
3
  * @import {Options} from 'sass'
4
4
  */
5
5
 
6
+ /**
7
+ * @typedef {Object} CoraliteStaticAsset
8
+ * @property {string} pkg - The package name to copy assets from.
9
+ * @property {string} path - The path to the asset within the package.
10
+ * @property {string} dest - The destination path for the asset in the output directory.
11
+ */
12
+
6
13
  /**
7
14
  * @typedef {Object} CoraliteScriptBaseConfig
8
15
  * @property {string} public - The path to the directory containing static assets.
16
+ * @property {CoraliteStaticAsset[]} [assets] - Static assets to copy during build.
9
17
  * @property {Object} [server] - Server configuration options.
10
18
  * @property {number} server.port - The port number on which the development server will run.
11
19
  * @property {Object} [styles]