coralite-scripts 0.29.2 → 0.29.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/bin/index.js +22 -3
- package/libs/server.js +21 -5
- package/package.json +2 -2
package/bin/index.js
CHANGED
|
@@ -60,13 +60,16 @@ if (mode === 'dev') {
|
|
|
60
60
|
deleteDirectoryRecursive(config.output)
|
|
61
61
|
|
|
62
62
|
const start = process.hrtime()
|
|
63
|
+
|
|
63
64
|
// start coralite
|
|
64
65
|
const coralite = new Coralite({
|
|
65
66
|
components: config.components,
|
|
66
67
|
pages: config.pages,
|
|
67
68
|
plugins: config.plugins,
|
|
68
69
|
assets: config.assets,
|
|
69
|
-
|
|
70
|
+
baseURL: config.baseURL,
|
|
71
|
+
output: config.output,
|
|
72
|
+
mode: 'production'
|
|
70
73
|
})
|
|
71
74
|
await coralite.initialise()
|
|
72
75
|
|
|
@@ -99,6 +102,22 @@ if (mode === 'dev') {
|
|
|
99
102
|
return outFile
|
|
100
103
|
})
|
|
101
104
|
|
|
105
|
+
// Write ESM script assets generated during the build phase
|
|
106
|
+
if (coralite.outputFiles) {
|
|
107
|
+
const assetsDir = join(config.output, 'assets', 'js')
|
|
108
|
+
await mkdir(assetsDir, { recursive: true })
|
|
109
|
+
|
|
110
|
+
const assetWrites = Object.values(coralite.outputFiles).map(async (file) => {
|
|
111
|
+
const outFile = join(assetsDir, file.hashedPath)
|
|
112
|
+
await writeFile(outFile, file.text)
|
|
113
|
+
if (options.verbose) {
|
|
114
|
+
process.stdout.write(toTime() + toMS(0) + dash + outFile + '\n')
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
await Promise.all(assetWrites)
|
|
119
|
+
}
|
|
120
|
+
|
|
102
121
|
if (!options.verbose) {
|
|
103
122
|
spinner.succeed(`Pages built (${pageCount} completed)`)
|
|
104
123
|
if (componentCount > 0) {
|
|
@@ -126,7 +145,7 @@ if (mode === 'dev') {
|
|
|
126
145
|
if (config.styles.type === 'sass' || config.styles.type === 'scss') {
|
|
127
146
|
const results = await buildSass({
|
|
128
147
|
input: config.styles.input,
|
|
129
|
-
output: join(config.output, 'css'),
|
|
148
|
+
output: join(config.output, 'assets', 'css'),
|
|
130
149
|
options: config.sassOptions,
|
|
131
150
|
start
|
|
132
151
|
})
|
|
@@ -141,7 +160,7 @@ if (mode === 'dev') {
|
|
|
141
160
|
} else if (config.styles.type === 'css') {
|
|
142
161
|
const results = await buildCSS({
|
|
143
162
|
input: config.styles.input,
|
|
144
|
-
output: join(config.output, 'css'),
|
|
163
|
+
output: join(config.output, 'assets', 'css'),
|
|
145
164
|
plugins: config.cssPlugins,
|
|
146
165
|
start
|
|
147
166
|
})
|
package/libs/server.js
CHANGED
|
@@ -38,6 +38,7 @@ async function server (config, options) {
|
|
|
38
38
|
pages: config.pages,
|
|
39
39
|
plugins: config.plugins,
|
|
40
40
|
assets: config.assets,
|
|
41
|
+
baseURL: config.baseURL,
|
|
41
42
|
ignoreByAttribute: config.ignoreByAttribute,
|
|
42
43
|
skipRenderByAttribute: config.skipRenderByAttribute,
|
|
43
44
|
mode: 'development',
|
|
@@ -109,7 +110,7 @@ async function server (config, options) {
|
|
|
109
110
|
|
|
110
111
|
watchPath.push(config.styles.input)
|
|
111
112
|
|
|
112
|
-
app.use('/css', express.static(join(config.output, 'css'), {
|
|
113
|
+
app.use('/assets/css', express.static(join(config.output, 'assets', 'css'), {
|
|
113
114
|
cacheControl: false
|
|
114
115
|
}))
|
|
115
116
|
} else {
|
|
@@ -122,7 +123,7 @@ async function server (config, options) {
|
|
|
122
123
|
// rebuild CSS and send notification
|
|
123
124
|
const results = await buildSass({
|
|
124
125
|
...config.styles,
|
|
125
|
-
output: join(config.output, 'css'),
|
|
126
|
+
output: join(config.output, 'assets', 'css'),
|
|
126
127
|
start
|
|
127
128
|
})
|
|
128
129
|
|
|
@@ -138,7 +139,7 @@ async function server (config, options) {
|
|
|
138
139
|
|
|
139
140
|
await buildCSS({
|
|
140
141
|
input: config.styles.input,
|
|
141
|
-
output: join(config.output, 'css'),
|
|
142
|
+
output: join(config.output, 'assets', 'css'),
|
|
142
143
|
plugins: config.cssPlugins,
|
|
143
144
|
start
|
|
144
145
|
})
|
|
@@ -294,6 +295,21 @@ async function server (config, options) {
|
|
|
294
295
|
}
|
|
295
296
|
})
|
|
296
297
|
|
|
298
|
+
// Write ESM script assets generated during the build phase
|
|
299
|
+
if (coralite.outputFiles) {
|
|
300
|
+
const assetsDir = join(config.output, 'assets', 'js')
|
|
301
|
+
if (!existsSync(assetsDir)) {
|
|
302
|
+
await mkdir(assetsDir, { recursive: true })
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const assetWrites = Object.values(coralite.outputFiles).map(async (file) => {
|
|
306
|
+
const outFile = join(assetsDir, file.hashedPath)
|
|
307
|
+
await writeFile(outFile, file.text)
|
|
308
|
+
})
|
|
309
|
+
|
|
310
|
+
await Promise.all(assetWrites)
|
|
311
|
+
}
|
|
312
|
+
|
|
297
313
|
// prints time and path to the file that has been changed or added.
|
|
298
314
|
duration = process.hrtime(start)
|
|
299
315
|
process.stdout.write(toTime() + colours.bgGreen(' Compiled HTML ') + dash + toMS(duration) + dash + '/' + cacheKey + '\n')
|
|
@@ -371,7 +387,7 @@ async function server (config, options) {
|
|
|
371
387
|
const results = await buildSass({
|
|
372
388
|
input: config.styles.input,
|
|
373
389
|
options: config.sassOptions,
|
|
374
|
-
output: join(config.output, 'css'),
|
|
390
|
+
output: join(config.output, 'assets', 'css'),
|
|
375
391
|
start
|
|
376
392
|
})
|
|
377
393
|
|
|
@@ -384,7 +400,7 @@ async function server (config, options) {
|
|
|
384
400
|
if (cssChanges.length > 0) {
|
|
385
401
|
const results = await buildCSS({
|
|
386
402
|
input: config.styles.input,
|
|
387
|
-
output: join(config.output, 'css'),
|
|
403
|
+
output: join(config.output, 'assets', 'css'),
|
|
388
404
|
plugins: config.cssPlugins,
|
|
389
405
|
start
|
|
390
406
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coralite-scripts",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.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.29.
|
|
61
|
+
"coralite": "0.29.3"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "premove dist && pnpm build-types",
|