jizy-packer 2.1.2 → 2.1.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.
Files changed (3) hide show
  1. package/README.md +23 -29
  2. package/lib/Rollup.js +1 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -15,9 +15,9 @@ A CLI tool and Node.js library to generate optimized builds for your projects. I
15
15
  ### CLI
16
16
 
17
17
  ```sh
18
- node lib/Cli.js
19
- node lib/Cli.js --action build --name perso --config { "key": "value" }
20
- node lib/Cli.js --action build --name perso --config ABSOLUTE_PATH_TO_JSON_FILE
18
+ node ./cli/jpack.js --debug
19
+ node ./cli/jpack.js --action build --name perso --config { "key": "value" }
20
+ node ./cli/jpack.js --action build --name perso --config ABSOLUTE_PATH_TO_JSON_FILE
21
21
  ```
22
22
 
23
23
  Options:
@@ -45,11 +45,11 @@ Example from the "jizy-browser" extension.
45
45
 
46
46
  ***First for the default dist build***
47
47
 
48
- #### ./config/config.json
49
- ```json
50
- {
51
- "desktopBreakpoint": "900px"
52
- }
48
+ #### ./cli/jpack.js
49
+ ```js
50
+ import { jPackCli } from 'jizy-packer';
51
+ import jPackData from '../config/jpack.js';
52
+ jPackCli(jPackData);
53
53
  ```
54
54
 
55
55
  #### ./config/jpack.js
@@ -58,34 +58,28 @@ import fs from 'fs';
58
58
  import path from 'path';
59
59
  import { LogMe, jPackConfig } from 'jizy-packer';
60
60
 
61
- const jPackData = {
62
- name: 'BrowserCompat',
63
- alias: 'jizy-browser',
64
-
65
- onCheckConfig: () => {
66
- // add some config validation
67
- const desktopBreakpoint = jPackConfig.get('desktopBreakpoint');
68
- if (!desktopBreakpoint) {
69
- LogMe.error('Missing desktopBreakpoint in config');
70
- process.exit(1);
71
- }
72
- },
73
-
74
- // generate config.less
75
- onGenerateBuildJs: (code) => {
61
+ const jPackData = function () {
62
+ jPackConfig.sets({
63
+ name: 'BrowserCompat',
64
+ alias: 'jizy-browser',
65
+ desktopBreakpoint: "900px"
66
+ });
67
+
68
+ jPackConfig.set('onCheckConfig', () => { });
69
+
70
+ jPackConfig.set('onGenerateBuildJs', (code) => {
76
71
  LogMe.log('Generate config.less');
72
+ LogMe.log(' path: ' + path.join(jPackConfig.get('targetPath'), 'config.less'));
77
73
  const desktopBreakpoint = jPackConfig.get('desktopBreakpoint') ?? '768px';
78
- let lessContent = `@desktop-breakpoint: ${desktopBreakpoint};\n`;
74
+ let lessContent = `@desktop-breakpoint: ${desktopBreakpoint};` + "\n";
79
75
  lessContent += `@mobile-breakpoint: @desktop-breakpoint - 1px;`;
80
76
  fs.writeFileSync(path.join(jPackConfig.get('targetPath'), 'config.less'), lessContent);
81
77
  return code;
82
- },
78
+ });
83
79
 
84
- // parse wrapped js
85
- onGenerateWrappedJs: (wrapped) => wrapped,
80
+ jPackConfig.set('onGenerateWrappedJs', (wrapped) => wrapped);
86
81
 
87
- // after packing
88
- onPacked: () => { }
82
+ jPackConfig.set('onPacked', () => { });
89
83
  };
90
84
 
91
85
  export default jPackData;
package/lib/Rollup.js CHANGED
@@ -73,9 +73,6 @@ export default async function jPackRollup(config) {
73
73
  ];
74
74
  };
75
75
 
76
- function cleanBuildFolder() {
77
- }
78
-
79
76
  function generateBuildJs() {
80
77
  LogMe.log('Generate the build.js file ...');
81
78
 
@@ -90,6 +87,7 @@ function generateBuildJs() {
90
87
  }
91
88
 
92
89
  code = code.replace(/{{PREFIX}}/g, jPackConfig.get('importPrefix'));
90
+ code = code.replace(/{{TARGET_REL_PATH}}/g, jPackConfig.get('targetRelativePath'));
93
91
 
94
92
  fs.writeFileSync(jPackConfig.get('buildJsFilePath'), code, 'utf8');
95
93
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jizy-packer",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "lib/*.js"