leanweb 2.0.0 → 2.0.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.
- package/commands/build.js +3 -2
- package/commands/dist.js +11 -2
- package/package.json +1 -1
package/commands/build.js
CHANGED
|
@@ -10,6 +10,7 @@ import fse from 'fs-extra';
|
|
|
10
10
|
import { minify } from 'html-minifier';
|
|
11
11
|
import * as utils from './utils.js';
|
|
12
12
|
import * as parser from '../lib/lw-html-parser.js';
|
|
13
|
+
import CleanCSS from 'clean-css';
|
|
13
14
|
|
|
14
15
|
(async () => {
|
|
15
16
|
let env;
|
|
@@ -60,7 +61,6 @@ import * as parser from '../lib/lw-html-parser.js';
|
|
|
60
61
|
scssString += '\n[lw-false],[lw-for]{display:none !important;}\n';
|
|
61
62
|
cssString = utils.buildCSS(scssString, utils.dirs.build, `${utils.dirs.build}/components/${cmp}`);
|
|
62
63
|
}
|
|
63
|
-
const styleString = cssString || '';
|
|
64
64
|
const htmlString = fs.readFileSync(htmlFilename, 'utf8');
|
|
65
65
|
const minifiedHtml = minify(htmlString, {
|
|
66
66
|
caseSensitive: true,
|
|
@@ -70,7 +70,8 @@ import * as parser from '../lib/lw-html-parser.js';
|
|
|
70
70
|
removeComments: true,
|
|
71
71
|
});
|
|
72
72
|
const ast = parser.parse(minifiedHtml);
|
|
73
|
-
|
|
73
|
+
const minifiedCss = new CleanCSS({}).minify(cssString ?? '');
|
|
74
|
+
ast.css = minifiedCss.styles ?? '';
|
|
74
75
|
ast.componentFullName = project.name + '-' + cmp.replace(/\//g, '-');
|
|
75
76
|
ast.runtimeVersion = project.version;
|
|
76
77
|
ast.builderVersion = leanwebPackageJSON.version;
|
package/commands/dist.js
CHANGED
|
@@ -15,6 +15,8 @@ if (args.length >= 3) {
|
|
|
15
15
|
env = args[2];
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
const verbose = process.env.verbose || false;
|
|
19
|
+
|
|
18
20
|
(async () => {
|
|
19
21
|
const project = require(`${process.cwd()}/${utils.dirs.src}/leanweb.json`);
|
|
20
22
|
|
|
@@ -22,12 +24,19 @@ if (args.length >= 3) {
|
|
|
22
24
|
await utils.exec(`npx leanweb build ${env}`);
|
|
23
25
|
|
|
24
26
|
fs.mkdirSync(utils.dirs.dist, { recursive: true });
|
|
25
|
-
esbuild.build({
|
|
27
|
+
const result = await esbuild.build({
|
|
26
28
|
entryPoints: [`./${utils.dirs.build}/${project.name}.js`],
|
|
27
29
|
bundle: true,
|
|
30
|
+
minify: true,
|
|
31
|
+
sourcemap: true,
|
|
28
32
|
format: 'esm',
|
|
29
33
|
outfile: `./${utils.dirs.dist}/${project.name}.js`,
|
|
30
|
-
|
|
34
|
+
metafile: !!verbose,
|
|
35
|
+
});
|
|
36
|
+
if (verbose) {
|
|
37
|
+
const text = await esbuild.analyzeMetafile(result.metafile);
|
|
38
|
+
console.log(text);
|
|
39
|
+
}
|
|
31
40
|
|
|
32
41
|
const indexHTML = fs.readFileSync(`./${utils.dirs.build}/index.html`, 'utf8');
|
|
33
42
|
const minifiedIndexHtml = minify(indexHTML, {
|