apexcss-cli 0.1.0 → 0.1.1

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.
@@ -7,6 +7,7 @@ import { resolve, dirname } from 'node:path';
7
7
  import { fileURLToPath } from 'node:url';
8
8
  import { loadConfig } from '../utils/config-loader.js';
9
9
  import { logger } from '../utils/logger.js';
10
+ import * as sass from 'sass';
10
11
 
11
12
  const __filename = fileURLToPath(import.meta.url);
12
13
  const __dirname = dirname(__filename);
@@ -228,11 +229,11 @@ export async function buildCommand(options) {
228
229
  const entryContent = generateLayerEntry(layers);
229
230
  writeFileSync(resolve(tempDir, 'apex-entry.scss'), entryContent);
230
231
 
231
- // Build using Vite programmatically
232
+ // Build using Sass compiler
232
233
  logger.info('Compiling CSS...');
233
234
 
234
235
  try {
235
- await runViteBuild(tempDir, options, outputDir, layers, scssContent);
236
+ await runSassBuild(tempDir, options, outputDir, layers, scssContent);
236
237
 
237
238
  const duration = Date.now() - startTime;
238
239
  logger.newline();
@@ -248,7 +249,7 @@ export async function buildCommand(options) {
248
249
  }
249
250
 
250
251
  /**
251
- * Run Vite build
252
+ * Run Sass build
252
253
  * @param {string} tempDir - Temp directory path
253
254
  * @param {object} options - Build options
254
255
  * @param {string} outputDir - Output directory path
@@ -256,75 +257,35 @@ export async function buildCommand(options) {
256
257
  * @param {string} scssContent - SCSS content
257
258
  * @returns {Promise<void>}
258
259
  */
259
- async function runViteBuild(tempDir, options, outputDir, layers, scssContent) {
260
- const { build } = await import('vite');
261
- const cwd = process.cwd();
262
-
263
- // Look for postcss config in user's project
264
- const userPostcssConfig = resolve(cwd, 'postcss.config.js');
265
- const apexcssPostcssConfig = resolve(cwd, 'node_modules', 'apexcss', 'postcss.config.js');
266
-
267
- let postcssConfig;
268
- if (existsSync(userPostcssConfig)) {
269
- postcssConfig = userPostcssConfig;
270
- } else if (existsSync(apexcssPostcssConfig)) {
271
- postcssConfig = apexcssPostcssConfig;
272
- } else {
273
- postcssConfig = undefined;
274
- }
275
-
276
- await build({
277
- configFile: false,
278
- css: {
279
- postcss: postcssConfig
280
- },
281
- build: {
282
- cssCodeSplit: false,
283
- sourcemap: options.sourcemap,
284
- minify: options.minify ? 'esbuild' : false,
285
- outDir: tempDir,
286
- rollupOptions: {
287
- input: {
288
- apex: resolve(tempDir, 'apex-entry.scss')
289
- },
290
- output: {
291
- entryFileNames: '[name].js',
292
- assetFileNames: () => '[name][extname]'
293
- }
294
- }
295
- }
260
+ async function runSassBuild(tempDir, options, outputDir, layers, scssContent) {
261
+ const entryFile = resolve(tempDir, 'apex-entry.scss');
262
+
263
+ // Compile SCSS to CSS using Sass
264
+ const result = sass.compile(entryFile, {
265
+ loadPaths: [tempDir],
266
+ sourceMap: options.sourcemap,
267
+ style: options.minify ? 'compressed' : 'expanded'
296
268
  });
297
269
 
298
270
  // Get output filenames based on layers
299
271
  const { filename, description } = getOutputFilenames(layers);
300
272
 
301
- // Copy CSS from temp to output
302
- const generatedCssPath = findGeneratedCss(tempDir);
273
+ // Write CSS output
303
274
  const finalCssPath = resolve(outputDir, `${filename}.css`);
304
-
305
- if (!generatedCssPath) {
306
- throw new Error('CSS file was not generated');
307
- }
308
-
309
- const cssContent = readFileSync(generatedCssPath, 'utf-8');
310
- writeFileSync(finalCssPath, cssContent);
275
+ writeFileSync(finalCssPath, result.css);
311
276
 
312
277
  // Calculate file size
313
- const contentBytes = Buffer.byteLength(cssContent, 'utf8');
278
+ const contentBytes = Buffer.byteLength(result.css, 'utf8');
314
279
  const sizeKB = (contentBytes / 1024).toFixed(2);
315
280
 
316
281
  const filePath = logger.path(`${filename}.css`);
317
282
  logger.success(`Built: ${filePath} (${sizeKB} KB) [${description}]`);
318
283
 
319
- // Copy source map if generated
320
- if (options.sourcemap) {
321
- const mapSource = resolve(tempDir, 'apex.css.map');
284
+ // Write source map if generated
285
+ if (options.sourcemap && result.sourceMap) {
322
286
  const mapDest = resolve(outputDir, `${filename}.css.map`);
323
- if (existsSync(mapSource)) {
324
- const mapContent = readFileSync(mapSource, 'utf-8');
325
- writeFileSync(mapDest, mapContent);
326
- logger.success('Source map generated');
327
- }
287
+ writeFileSync(mapDest, JSON.stringify(result.sourceMap));
288
+ logger.success('Source map generated');
328
289
  }
329
290
 
330
291
  // Output SCSS if requested
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apexcss-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "ApexCSS CLI - Build and customize your CSS framework",
5
5
  "type": "module",
6
6
  "main": "cli/index.js",
@@ -62,7 +62,7 @@
62
62
  "inquirer": "^9.2.0"
63
63
  },
64
64
  "peerDependencies": {
65
- "apexcss": ">=0.3.0",
65
+ "apexcss": "^0.4.1",
66
66
  "sass": ">=1.90.0",
67
67
  "vite": ">=7.0.0"
68
68
  },