@haptiq/kit 0.1.1 → 0.3.0

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/haptiq.kit.js CHANGED
@@ -127,19 +127,21 @@ program
127
127
  program
128
128
  .command('css')
129
129
  .description('Build CSS from Sass and CSS files')
130
+ .option('--dev', 'Build without minification')
130
131
  .option('--verbose', 'Show detailed output for each file processed')
131
132
  .action(createCommandHandler('CSS build', async (config, options) => {
132
- await buildCSS(config, options.verbose);
133
+ await buildCSS(config, options.verbose, options.dev);
133
134
  }));
134
135
 
135
136
  program
136
137
  .command('js')
137
138
  .description('Bundle JavaScript files with Terser')
139
+ .option('--dev', 'Build without minification')
138
140
  .option('--verbose', 'Show detailed output for bundling process')
139
141
  .option('--only <name>', 'Only run the named configuration')
140
142
  .option('--skip <name>', 'Skip the named configuration')
141
143
  .action(createCommandHandler('JavaScript build', async (config, options) => {
142
- await buildJS(config, options.verbose, { only: options.only, skip: options.skip });
144
+ await buildJS(config, options.verbose, { only: options.only, skip: options.skip, dev: options.dev });
143
145
  }));
144
146
 
145
147
  program.parse();
package/lib/css.js CHANGED
@@ -8,7 +8,9 @@ import fs from 'fs';
8
8
  import path from 'path';
9
9
  import { globSync } from 'glob';
10
10
  import * as sass from 'sass';
11
- import { transform } from 'lightningcss';
11
+ import { transform, browserslistToTargets } from 'lightningcss';
12
+ import browserslist from 'browserslist';
13
+ import haptiqBrowserslistConfig from '@haptiq/browserslist-config';
12
14
 
13
15
 
14
16
  /**
@@ -21,13 +23,20 @@ import { transform } from 'lightningcss';
21
23
  *
22
24
  * @param {Object} config - Configuration object from haptiq.config.js
23
25
  * @param {boolean} verbose - Show detailed processing logs
26
+ * @param {boolean} dev - Skip minification (--dev flag)
24
27
  * @returns {Promise<void>}
25
28
  * @see {@link ../examples/haptiq.config.js} for all available options
26
29
  */
27
- async function buildCSS(config = {}, verbose = false) {
30
+ async function buildCSS(config = {}, verbose = false, dev = false) {
31
+ // Use project's own browserslist config if present, otherwise fall back to @haptiq/browserslist-config
32
+ const projectConfig = browserslist.loadConfig({ path: process.cwd() });
33
+ const resolvedTargets = browserslistToTargets(
34
+ browserslist(projectConfig ?? haptiqBrowserslistConfig, { path: process.cwd() })
35
+ );
36
+
28
37
  const defaultLightningConfig = {
29
- targets: { chrome: 80, firefox: 90, safari: 14 },
30
- minify: true,
38
+ targets: resolvedTargets,
39
+ minify: !dev,
31
40
  sourceMap: true
32
41
  };
33
42
 
@@ -35,10 +44,10 @@ async function buildCSS(config = {}, verbose = false) {
35
44
  src: 'src/**/*.{scss,sass,css}',
36
45
  dest: 'css',
37
46
  ...config.css,
38
- // Merge lightning config properly (after user config)
39
47
  lightning: {
40
48
  ...defaultLightningConfig,
41
- ...config.css?.lightning
49
+ ...config.css?.lightning,
50
+ ...(dev && { minify: false })
42
51
  }
43
52
  };
44
53
 
package/lib/js.js CHANGED
@@ -18,7 +18,7 @@ import { minify } from 'terser';
18
18
  *
19
19
  * @param {Object} config - Configuration object from haptiq.config.js
20
20
  * @param {boolean} verbose - Show detailed processing logs
21
- * @param {{ only?: string, skip?: string }} options - CLI filter options
21
+ * @param {{ only?: string, skip?: string, dev?: boolean }} options - CLI filter options
22
22
  * @returns {Promise<void>}
23
23
  */
24
24
  async function buildJS(config = {}, verbose = false, options = {}) {
@@ -31,7 +31,7 @@ async function buildJS(config = {}, verbose = false, options = {}) {
31
31
  if (options.only || options.skip) {
32
32
  console.warn('⚠️ --only and --skip have no effect with a single configuration');
33
33
  }
34
- await processSingleConfig(jsConfig, verbose);
34
+ await processSingleConfig(jsConfig, verbose, options.dev ?? false);
35
35
  }
36
36
 
37
37
  console.log(`✅ JavaScript processing completed.`);
@@ -43,10 +43,11 @@ async function buildJS(config = {}, verbose = false, options = {}) {
43
43
  *
44
44
  * @param {Object} configs - Object with named configurations
45
45
  * @param {boolean} verbose - Show detailed processing logs
46
- * @param {{ only?: string, skip?: string }} options - CLI filter options
46
+ * @param {{ only?: string, skip?: string, dev?: boolean }} options - CLI filter options
47
47
  * @returns {Promise<void>}
48
48
  */
49
49
  async function processMultipleConfigs(configs, verbose, options = {}) {
50
+ const dev = options.dev ?? false;
50
51
  const configNames = Object.keys(configs);
51
52
 
52
53
  let configsToProcess = configNames;
@@ -67,7 +68,7 @@ async function processMultipleConfigs(configs, verbose, options = {}) {
67
68
  }
68
69
 
69
70
  for (const configName of configsToProcess) {
70
- await processSingleConfig(configs[configName], verbose);
71
+ await processSingleConfig(configs[configName], verbose, dev);
71
72
  if (verbose) {
72
73
  console.log(` ✅ [${configName}] done`);
73
74
  }
@@ -82,7 +83,7 @@ async function processMultipleConfigs(configs, verbose, options = {}) {
82
83
  * @param {boolean} verbose - Show detailed processing logs
83
84
  * @returns {Promise<void>}
84
85
  */
85
- async function processSingleConfig(jsConfig, verbose) {
86
+ async function processSingleConfig(jsConfig, verbose, dev = false) {
86
87
  const dest = jsConfig.dest || 'js/bundle.js';
87
88
  let combine = jsConfig.combine;
88
89
  if (combine === undefined) {
@@ -96,7 +97,8 @@ async function processSingleConfig(jsConfig, verbose) {
96
97
  combine,
97
98
  terser: {
98
99
  sourceMap: true,
99
- ...jsConfig.terser
100
+ ...jsConfig.terser,
101
+ ...(dev && { compress: false, mangle: false, format: { beautify: true } })
100
102
  }
101
103
  };
102
104
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haptiq/kit",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "description": "Build tools for Haptiq projects.",
5
5
  "keywords": [
6
6
  "build",
@@ -10,20 +10,23 @@
10
10
  ],
11
11
  "author": "Haptiq",
12
12
  "license": "GPL-2.0-or-later",
13
- "homepage": "...",
13
+ "homepage": "https://github.com/haptiq/haptiq-kit/blob/main/packages/kit/README.md",
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "..."
16
+ "url": "git+https://github.com/haptiq/haptiq-kit.git",
17
+ "directory": "packages/kit"
17
18
  },
18
19
  "type": "module",
19
20
  "bin": {
20
21
  "kit": "bin/haptiq.kit.js"
21
22
  },
22
23
  "dependencies": {
24
+ "@haptiq/browserslist-config": "^0.1.0",
25
+ "browserslist": "^4.28.2",
23
26
  "commander": "^15.0.0",
24
- "sass": "^1.101.0",
25
- "lightningcss": "^1.32.0",
26
27
  "glob": "^13.0.6",
28
+ "lightningcss": "^1.32.0",
29
+ "sass": "^1.101.0",
27
30
  "terser": "^5.0.0"
28
31
  },
29
32
  "engines": {