coralite-scripts 0.38.2 → 0.38.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 CHANGED
@@ -174,7 +174,9 @@ if (mode === 'dev') {
174
174
  const results = await buildStyles({
175
175
  input: config.styles.input,
176
176
  output: join(config.output, 'assets', 'css'),
177
- processors: config.styles.processors
177
+ processors: config.styles.processors,
178
+ minify: mode === 'build',
179
+ sourcemap: mode !== 'build'
178
180
  })
179
181
 
180
182
  for (let i = 0; i < results.length; i++) {
@@ -2,6 +2,7 @@ import * as sass from 'sass'
2
2
  import postcss from 'postcss'
3
3
  import fs from 'fs/promises'
4
4
  import path from 'path'
5
+ import { transform } from 'esbuild'
5
6
 
6
7
  /**
7
8
  * @typedef {Object} BuildStylesResult
@@ -16,15 +17,19 @@ import path from 'path'
16
17
  * @param {string[]} options.input - Array of input file paths
17
18
  * @param {string} options.output - Output directory for compiled CSS files
18
19
  * @param {Object} [options.processors] - Processor configurations
20
+ * @param {boolean} [options.minify=false] - Whether to minify the output
21
+ * @param {boolean} [options.sourcemap=true] - Whether to generate source maps
19
22
  * @returns {Promise<BuildStylesResult[]>}
20
23
  */
21
24
  async function buildStyles ({
22
25
  input,
23
26
  output,
24
- processors = {}
27
+ processors = {},
28
+ minify = false,
29
+ sourcemap = true
25
30
  }) {
26
31
  const scssOptions = {
27
- sourceMap: true,
32
+ sourceMap: sourcemap,
28
33
  loadPaths: ['node_modules'],
29
34
  // @ts-ignore
30
35
  silenceDeprecations: [
@@ -62,13 +67,26 @@ async function buildStyles ({
62
67
  const postcssOptions = {
63
68
  from: filePath,
64
69
  to: outputFile,
65
- map: map ? { prev: map } : true
70
+ map: (sourcemap && map) ? { prev: map } : sourcemap
66
71
  }
67
72
  const result = await postcss(postcssPlugins).process(css, postcssOptions)
68
73
  css = result.css
69
74
  map = result.map
70
75
  }
71
76
 
77
+ if (minify) {
78
+ const result = await transform(css, {
79
+ loader: 'css',
80
+ minify: true,
81
+ sourcemap: sourcemap ? 'external' : false,
82
+ sourcefile: filePath
83
+ })
84
+ css = result.code
85
+ if (sourcemap && result.map) {
86
+ map = result.map
87
+ }
88
+ }
89
+
72
90
  const duration = process.hrtime(fileStart)
73
91
 
74
92
  await fs.mkdir(output, { recursive: true })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coralite-scripts",
3
- "version": "0.38.2",
3
+ "version": "0.38.4",
4
4
  "description": "Configuration and scripts for Create Coralite.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -61,7 +61,7 @@
61
61
  "portfinder": "^1.0.38",
62
62
  "postcss": "^8.5.6",
63
63
  "sass": "^1.91.0",
64
- "coralite": "0.38.2"
64
+ "coralite": "0.38.4"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "premove dist && pnpm build-types",