@haptiq/kit 0.2.0 → 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 +4 -2
- package/lib/css.js +5 -4
- package/lib/js.js +8 -6
- package/package.json +1 -1
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
|
@@ -23,10 +23,11 @@ import haptiqBrowserslistConfig from '@haptiq/browserslist-config';
|
|
|
23
23
|
*
|
|
24
24
|
* @param {Object} config - Configuration object from haptiq.config.js
|
|
25
25
|
* @param {boolean} verbose - Show detailed processing logs
|
|
26
|
+
* @param {boolean} dev - Skip minification (--dev flag)
|
|
26
27
|
* @returns {Promise<void>}
|
|
27
28
|
* @see {@link ../examples/haptiq.config.js} for all available options
|
|
28
29
|
*/
|
|
29
|
-
async function buildCSS(config = {}, verbose = false) {
|
|
30
|
+
async function buildCSS(config = {}, verbose = false, dev = false) {
|
|
30
31
|
// Use project's own browserslist config if present, otherwise fall back to @haptiq/browserslist-config
|
|
31
32
|
const projectConfig = browserslist.loadConfig({ path: process.cwd() });
|
|
32
33
|
const resolvedTargets = browserslistToTargets(
|
|
@@ -35,7 +36,7 @@ async function buildCSS(config = {}, verbose = false) {
|
|
|
35
36
|
|
|
36
37
|
const defaultLightningConfig = {
|
|
37
38
|
targets: resolvedTargets,
|
|
38
|
-
minify:
|
|
39
|
+
minify: !dev,
|
|
39
40
|
sourceMap: true
|
|
40
41
|
};
|
|
41
42
|
|
|
@@ -43,10 +44,10 @@ async function buildCSS(config = {}, verbose = false) {
|
|
|
43
44
|
src: 'src/**/*.{scss,sass,css}',
|
|
44
45
|
dest: 'css',
|
|
45
46
|
...config.css,
|
|
46
|
-
// Merge lightning config properly (after user config)
|
|
47
47
|
lightning: {
|
|
48
48
|
...defaultLightningConfig,
|
|
49
|
-
...config.css?.lightning
|
|
49
|
+
...config.css?.lightning,
|
|
50
|
+
...(dev && { minify: false })
|
|
50
51
|
}
|
|
51
52
|
};
|
|
52
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
|
|