@changke/staticnext-build 0.3.0 → 0.3.3

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/CHANGELOG.md CHANGED
@@ -4,10 +4,16 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## 0.3.0
7
+ ## 0.3.3
8
+ 2023-07-10
9
+ ### Fixed
10
+ - Exception if additional copy targets not provided
11
+
12
+ ## 0.3.0 - 0.3.2
8
13
  2023-07-09
9
14
  ### Added
10
15
  - Support additional "source/target" pairs in `copy` task
16
+ - Parameter `external` for esbuild when building CSS
11
17
 
12
18
  ## 0.2.4
13
19
  2023-07-01
package/build.mjs CHANGED
@@ -32,7 +32,7 @@ const tasks = {
32
32
  {sources: [`${conf.sourceRoot}/*`, `!${conf.sourceRoot}/*.d.ts`], target: conf.targetRoot},
33
33
  {sources: `${srcPaths.assets}/**/*`, target: tgtPaths.assets},
34
34
  {sources: `${srcPaths.modules}/**/assets/**/*`, target: tgtPaths.moduleAssets}
35
- ]),
35
+ ].concat(Config.getCopyPairs(conf.copyPairs, conf.sourceRoot, tgtPaths.assets))),
36
36
  markdown: () => markdown(
37
37
  srcPaths.markdown,
38
38
  [srcPaths.prototype, srcPaths.modules],
@@ -51,7 +51,7 @@ const tasks = {
51
51
  `${srcPaths.css}/index.css`,
52
52
  `${srcPaths.modules}/**/*.css`,
53
53
  `!${srcPaths.modules}/**/_*.css`
54
- ], tgtPaths.assets)
54
+ ], tgtPaths.assets, [`${conf.assetsUrlPath}/*`])
55
55
  };
56
56
 
57
57
  const paraDev = () => {
package/lib/config.mjs CHANGED
@@ -83,18 +83,22 @@ class Config {
83
83
  * Build (additional) copy pairs
84
84
  *
85
85
  * @param {STPair[]} copyPairs
86
- * @param {string} sourceRoot
87
- * @param {string} targetRoot
86
+ * @param {string} sourceBase
87
+ * @param {string} targetBase
88
88
  * @param {boolean} appendSourcePath
89
89
  */
90
- getCopyPairs = (copyPairs, sourceRoot, targetRoot, appendSourcePath = false) => {
91
- return copyPairs.map(pr => {
92
- if (appendSourcePath) {
93
- pr.sources = `${appendSourcePath}${pr.sources}`;
94
- }
95
- pr.target = `${targetRoot}${pr.target}`;
96
- return pr;
97
- });
90
+ getCopyPairs = (copyPairs, sourceBase, targetBase, appendSourcePath = false) => {
91
+ if (copyPairs && Array.isArray(copyPairs) && copyPairs.length > 0) {
92
+ return copyPairs.map(pr => {
93
+ if (appendSourcePath) {
94
+ pr.sources = `${appendSourcePath}${pr.sources}`;
95
+ }
96
+ pr.target = `${targetBase}${pr.target}`;
97
+ return pr;
98
+ });
99
+ } else {
100
+ return [];
101
+ }
98
102
  };
99
103
  }
100
104
 
@@ -8,9 +8,10 @@ import isEnvProd from '../is-prod.mjs';
8
8
  *
9
9
  * @param {string[]} sources
10
10
  * @param {string} targetPath
11
+ * @param {string[]} external
11
12
  * @return {Promise}
12
13
  */
13
- const styles = (sources, targetPath) => {
14
+ const styles = (sources, targetPath, external = []) => {
14
15
  console.log('=> styles');
15
16
  return globby(sources).then(entries => {
16
17
  return build({
@@ -19,7 +20,8 @@ const styles = (sources, targetPath) => {
19
20
  target: 'es2021',
20
21
  outdir: targetPath,
21
22
  sourcemap: !isEnvProd(),
22
- minify: isEnvProd()
23
+ minify: isEnvProd(),
24
+ external: external
23
25
  });
24
26
  });
25
27
  };
package/lib/vars.mjs CHANGED
@@ -45,6 +45,8 @@ const njkGlobals = {
45
45
  'assetsUrlPath': assetsUrlPath
46
46
  };
47
47
 
48
+ const copyPairs = [];
49
+
48
50
  /** @type {SNConfig} */
49
51
  const config = {
50
52
  sourceRoot,
@@ -57,7 +59,8 @@ const config = {
57
59
  mainEntryFile,
58
60
  assetsUrlPath,
59
61
  markdownEnabled,
60
- njkGlobals
62
+ njkGlobals,
63
+ copyPairs
61
64
  };
62
65
 
63
66
  export default config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@changke/staticnext-build",
3
- "version": "0.3.0",
3
+ "version": "0.3.3",
4
4
  "description": "Build scripts extracted from StaticNext seed project",
5
5
  "main": "index.js",
6
6
  "scripts": {