@soleil-se/build-app 1.4.2 → 1.6.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/index.js +4 -5
- package/package.json +24 -26
- package/rollup/api/getPostcssPlugin.js +4 -5
- package/rollup/api/getStringPlugin.js +5 -0
- package/rollup/api/getTerserPlugin.js +1 -1
- package/rollup/client.js +6 -9
- package/rollup/server.js +6 -11
- package/rollup/utils/onwarn.js +8 -2
- package/utils/files.js +31 -2
- package/rollup/api/getInsertPlugin.js +0 -14
- package/rollup/utils/moveCss.js +0 -10
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { getTimestamp, logError, logInfo, logStartup } from '@soleil-se/build-ut
|
|
|
6
6
|
import chalk from 'chalk';
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
|
-
input,
|
|
9
|
+
input, manifest, addonName, env, projectRoot, rollup, watchPaths, eslintPaths,
|
|
10
10
|
} from './config.js';
|
|
11
11
|
|
|
12
12
|
import { clean, copy, files, zip, eslint } from './utils/index.js';
|
|
@@ -14,7 +14,6 @@ import { client, server } from './rollup/index.js';
|
|
|
14
14
|
import { activate, upload, sign } from './requests/index.js';
|
|
15
15
|
import config from './config/index.js';
|
|
16
16
|
|
|
17
|
-
const cssOutput = type === 'webapp' ? './dist/src/css/app.css' : './dist/src/resource/client/app.css';
|
|
18
17
|
const zipPath = `./dist/${manifest.id}-${manifest.version}.zip`;
|
|
19
18
|
|
|
20
19
|
async function main() {
|
|
@@ -36,7 +35,7 @@ async function main() {
|
|
|
36
35
|
debug: args.debug,
|
|
37
36
|
bundled: manifest.bundled,
|
|
38
37
|
cache: args.cache,
|
|
39
|
-
|
|
38
|
+
extractCss: true,
|
|
40
39
|
})),
|
|
41
40
|
task('client', client({
|
|
42
41
|
input: input.client,
|
|
@@ -45,7 +44,7 @@ async function main() {
|
|
|
45
44
|
globals: rollup?.client?.globals,
|
|
46
45
|
debug: args.debug,
|
|
47
46
|
cache: args.cache,
|
|
48
|
-
|
|
47
|
+
extractCss: true,
|
|
49
48
|
})),
|
|
50
49
|
task('hooks', server({
|
|
51
50
|
input: input.hooks,
|
|
@@ -53,7 +52,7 @@ async function main() {
|
|
|
53
52
|
bundled: manifest.bundled,
|
|
54
53
|
debug: args.debug,
|
|
55
54
|
cache: args.cache,
|
|
56
|
-
|
|
55
|
+
extractCss: true,
|
|
57
56
|
})),
|
|
58
57
|
task('config', config({ src: input.config, dest: './dist/src/config', cache: args.cache, debug: args.debug })),
|
|
59
58
|
task('globalConfig', config({ src: input.globalConfig, dest: './dist/src/config/global', cache: args.cache })),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soleil-se/build-app",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"bin": {
|
|
5
5
|
"build-app": "./bin/index.js",
|
|
6
6
|
"sv-app-build": "./bin/index.js"
|
|
@@ -14,43 +14,41 @@
|
|
|
14
14
|
},
|
|
15
15
|
"homepage": "https://docs.soleil.se/build/app",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@babel/core": "7.
|
|
18
|
-
"@babel/preset-env": "7.
|
|
19
|
-
"@rollup/plugin-alias": "
|
|
20
|
-
"@rollup/plugin-babel": "
|
|
21
|
-
"@rollup/plugin-commonjs": "
|
|
22
|
-
"@rollup/plugin-json": "
|
|
23
|
-
"@rollup/plugin-node-resolve": "
|
|
24
|
-
"@rollup/plugin-replace": "
|
|
25
|
-
"@
|
|
26
|
-
"@soleil-se/build-utils": "1.4.3",
|
|
17
|
+
"@babel/core": "7.20.12",
|
|
18
|
+
"@babel/preset-env": "7.20.2",
|
|
19
|
+
"@rollup/plugin-alias": "4.0.3",
|
|
20
|
+
"@rollup/plugin-babel": "6.0.3",
|
|
21
|
+
"@rollup/plugin-commonjs": "24.0.1",
|
|
22
|
+
"@rollup/plugin-json": "6.0.0",
|
|
23
|
+
"@rollup/plugin-node-resolve": "15.0.1",
|
|
24
|
+
"@rollup/plugin-replace": "5.0.2",
|
|
25
|
+
"@rollup/plugin-terser": "0.4.0",
|
|
27
26
|
"archiver": "5.3.1",
|
|
28
|
-
"autoprefixer": "10.4.
|
|
27
|
+
"autoprefixer": "10.4.13",
|
|
29
28
|
"babel-plugin-transform-async-to-promises": "0.8.18",
|
|
30
|
-
"chalk": "5.0
|
|
29
|
+
"chalk": "5.2.0",
|
|
31
30
|
"find-up": "6.3.0",
|
|
32
31
|
"form-data": "4.0.0",
|
|
33
|
-
"fs-extra": "
|
|
34
|
-
"glob": "^8.0
|
|
35
|
-
"got": "12.3
|
|
32
|
+
"fs-extra": "11.1.0",
|
|
33
|
+
"glob": "^8.1.0",
|
|
34
|
+
"got": "12.5.3",
|
|
36
35
|
"gzip-size": "7.0.0",
|
|
37
36
|
"lodash-es": "4.17.21",
|
|
38
|
-
"postcss": "8.4.
|
|
39
|
-
"postcss-discard-duplicates": "5.1.0",
|
|
37
|
+
"postcss": "8.4.21",
|
|
40
38
|
"postcss-pxtorem": "6.0.0",
|
|
41
|
-
"pretty-bytes": "6.
|
|
42
|
-
"rollup": "
|
|
39
|
+
"pretty-bytes": "6.1.0",
|
|
40
|
+
"rollup": "3.15.0",
|
|
43
41
|
"rollup-plugin-cleanup": "3.2.1",
|
|
44
|
-
"rollup-plugin-insert": "1.3.2",
|
|
45
42
|
"rollup-plugin-postcss": "4.0.2",
|
|
46
43
|
"rollup-plugin-string": "3.0.0",
|
|
47
|
-
"rollup-plugin-svelte": "7.1.
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
44
|
+
"rollup-plugin-svelte": "7.1.2",
|
|
45
|
+
"slash": "5.0.0",
|
|
46
|
+
"svelte-preprocess": "5.0.1",
|
|
47
|
+
"@soleil-se/build-config": "1.1.3",
|
|
48
|
+
"@soleil-se/build-utils": "1.4.3"
|
|
51
49
|
},
|
|
52
50
|
"devDependencies": {
|
|
53
|
-
"svelte": "3.
|
|
51
|
+
"svelte": "3.55.1"
|
|
54
52
|
},
|
|
55
53
|
"scripts": {},
|
|
56
54
|
"description": "Script for building WebApps, RESTApps and Widgets with Svelte in Sitevision.",
|
|
@@ -2,22 +2,21 @@ import postcss from 'rollup-plugin-postcss';
|
|
|
2
2
|
|
|
3
3
|
import autoprefixer from 'autoprefixer';
|
|
4
4
|
import pxtorem from 'postcss-pxtorem';
|
|
5
|
-
import discardDuplicates from 'postcss-discard-duplicates';
|
|
6
5
|
|
|
7
6
|
import config from '@soleil-se/build-config';
|
|
8
7
|
import preprocessOptions from './common/preprocessOptions.js';
|
|
9
8
|
|
|
10
|
-
const plugins = [autoprefixer(config?.css?.plugins?.autoprefixer)
|
|
9
|
+
const plugins = [autoprefixer(config?.css?.plugins?.autoprefixer)];
|
|
11
10
|
|
|
12
11
|
if (config?.css?.plugins?.pxtorem) {
|
|
13
12
|
plugins.push(pxtorem(config?.css.plugins.pxtorem));
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
export default function getPostcssPlugin({
|
|
15
|
+
export default function getPostcssPlugin({ extractCss, debug }) {
|
|
17
16
|
return postcss({
|
|
18
17
|
plugins,
|
|
19
|
-
extract:
|
|
20
|
-
minimize:
|
|
18
|
+
extract: extractCss,
|
|
19
|
+
minimize: { preset: 'default' },
|
|
21
20
|
sourceMap: debug ? 'inline' : false,
|
|
22
21
|
use: preprocessOptions,
|
|
23
22
|
});
|
package/rollup/client.js
CHANGED
|
@@ -3,7 +3,6 @@ import json from '@rollup/plugin-json';
|
|
|
3
3
|
|
|
4
4
|
import fse from 'fs-extra';
|
|
5
5
|
|
|
6
|
-
import moveCss from './utils/moveCss.js';
|
|
7
6
|
import onwarn from './utils/onwarn.js';
|
|
8
7
|
import getSitevisionClientPackages from './utils/getSitevisionClientPackages.js';
|
|
9
8
|
|
|
@@ -15,7 +14,7 @@ import getNodeResolvePlugin from './api/getNodeResolvePlugin.js';
|
|
|
15
14
|
import getSveltePlugin from './api/getSveltePlugin.js';
|
|
16
15
|
import getPostcssPlugin from './api/getPostcssPlugin.js';
|
|
17
16
|
import getTerserPlugin from './api/getTerserPlugin.js';
|
|
18
|
-
import
|
|
17
|
+
import getStringPlugin from './api/getStringPlugin.js';
|
|
19
18
|
|
|
20
19
|
import sitevision from './plugins/sitevisionClient.js';
|
|
21
20
|
import bundleSize from './plugins/bundleSize.js';
|
|
@@ -25,7 +24,7 @@ export default function rollupClient({
|
|
|
25
24
|
globals = {},
|
|
26
25
|
input,
|
|
27
26
|
output,
|
|
28
|
-
|
|
27
|
+
extractCss = false,
|
|
29
28
|
showSize = true,
|
|
30
29
|
bundled,
|
|
31
30
|
hydratable,
|
|
@@ -48,11 +47,11 @@ export default function rollupClient({
|
|
|
48
47
|
getAliasClientPlugin(),
|
|
49
48
|
getNodeResolvePlugin(),
|
|
50
49
|
getCommonjsPlugin(),
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
getPostcssPlugin({ cssOutput, debug }),
|
|
50
|
+
await getSveltePlugin({ input, debug, emitCss: extractCss, hydratable }),
|
|
51
|
+
getPostcssPlugin({ extractCss, debug }),
|
|
54
52
|
getBabelClientPlugin(),
|
|
55
53
|
json(),
|
|
54
|
+
getStringPlugin(),
|
|
56
55
|
showSize && bundleSize(),
|
|
57
56
|
getTerserPlugin({ debug }),
|
|
58
57
|
];
|
|
@@ -67,15 +66,13 @@ export default function rollupClient({
|
|
|
67
66
|
});
|
|
68
67
|
|
|
69
68
|
bundleCache = cache && bundle.cache;
|
|
70
|
-
|
|
69
|
+
return bundle.write({
|
|
71
70
|
file: output,
|
|
72
71
|
globals,
|
|
73
72
|
format: bundled ? 'amd' : 'iife',
|
|
74
73
|
sourcemap: debug ? 'inline' : false,
|
|
75
74
|
interop: 'auto',
|
|
76
75
|
});
|
|
77
|
-
|
|
78
|
-
return moveCss(cssOutput, output);
|
|
79
76
|
} catch (e) {
|
|
80
77
|
bundleCache = undefined;
|
|
81
78
|
throw e;
|
package/rollup/server.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { rollup } from 'rollup';
|
|
2
2
|
import json from '@rollup/plugin-json';
|
|
3
|
-
import { string } from 'rollup-plugin-string';
|
|
4
3
|
import cleanup from 'rollup-plugin-cleanup';
|
|
5
4
|
|
|
6
5
|
import fse from 'fs-extra';
|
|
7
6
|
|
|
8
|
-
import moveCss from './utils/moveCss.js';
|
|
9
7
|
import onwarn from './utils/onwarn.js';
|
|
10
8
|
|
|
11
9
|
import { getReplaceServerPlugin } from './api/getReplacePlugin.js';
|
|
12
10
|
import { getAliasServerPlugin } from './api/getAliasPlugin.js';
|
|
13
11
|
import { getBabelServerPlugin } from './api/getBabelPlugin.js';
|
|
14
12
|
import getCommonjsPlugin from './api/getCommonjsPlugin.js';
|
|
15
|
-
import getInsertPlugin from './api/getInsertPlugin.js';
|
|
16
13
|
import getNodeResolvePlugin from './api/getNodeResolvePlugin.js';
|
|
17
14
|
import getSveltePlugin from './api/getSveltePlugin.js';
|
|
18
15
|
import getPostcssPlugin from './api/getPostcssPlugin.js';
|
|
19
16
|
import getTerserPlugin from './api/getTerserPlugin.js';
|
|
17
|
+
import getStringPlugin from './api/getStringPlugin.js';
|
|
20
18
|
|
|
21
19
|
import sitevision from './plugins/sitevisionServer.js';
|
|
22
20
|
|
|
@@ -24,7 +22,7 @@ export default function rollupServer({
|
|
|
24
22
|
debug,
|
|
25
23
|
input,
|
|
26
24
|
output,
|
|
27
|
-
|
|
25
|
+
extractCss = false,
|
|
28
26
|
bundled,
|
|
29
27
|
cache = true,
|
|
30
28
|
} = {}) {
|
|
@@ -41,12 +39,11 @@ export default function rollupServer({
|
|
|
41
39
|
getAliasServerPlugin(),
|
|
42
40
|
sitevision(),
|
|
43
41
|
json(),
|
|
44
|
-
|
|
42
|
+
getStringPlugin(),
|
|
45
43
|
getNodeResolvePlugin(),
|
|
46
44
|
getCommonjsPlugin(),
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
getPostcssPlugin({ cssOutput, debug }),
|
|
45
|
+
await getSveltePlugin({ input, emitCss: extractCss, ssr: true }),
|
|
46
|
+
getPostcssPlugin({ extractCss, debug }),
|
|
50
47
|
getBabelServerPlugin(),
|
|
51
48
|
bundled ? getTerserPlugin({ debug }) : cleanup({ maxEmptyLines: 1 }),
|
|
52
49
|
];
|
|
@@ -60,13 +57,11 @@ export default function rollupServer({
|
|
|
60
57
|
});
|
|
61
58
|
|
|
62
59
|
bundleCache = cache && bundle.cache;
|
|
63
|
-
|
|
60
|
+
return bundle.write({
|
|
64
61
|
file: output,
|
|
65
62
|
intro: 'var Promise = Promise || { resolve: () => {} };',
|
|
66
63
|
format: 'iife',
|
|
67
64
|
});
|
|
68
|
-
|
|
69
|
-
return moveCss(cssOutput, output);
|
|
70
65
|
} catch (e) {
|
|
71
66
|
bundleCache = undefined;
|
|
72
67
|
throw e;
|
package/rollup/utils/onwarn.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { logWarning } from '@soleil-se/build-utils/log';
|
|
2
2
|
|
|
3
3
|
export default function onwarn(warning) {
|
|
4
|
+
let { message } = warning;
|
|
4
5
|
if (warning.code === 'CIRCULAR_DEPENDENCY') return;
|
|
5
6
|
|
|
6
7
|
if (warning.code === 'PLUGIN_WARNING') {
|
|
7
8
|
if (warning.pluginCode && warning.pluginCode === 'a11y-no-onchange') return;
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
if (warning.code === 'MISSING_NODE_BUILTINS') {
|
|
12
|
+
if (warning.ids.length === 1 && warning.ids[0] === 'events') return;
|
|
13
|
+
message = warning.message.replace(/"events", | and "events"|"events" and |"events"/g, '');
|
|
14
|
+
}
|
|
15
|
+
|
|
10
16
|
if (warning.code === 'UNRESOLVED_IMPORT') {
|
|
11
|
-
|
|
17
|
+
message = message.replace(' - treating it as an external dependency', '. Have you installed it?');
|
|
12
18
|
throw new Error(message);
|
|
13
19
|
}
|
|
14
|
-
logWarning(
|
|
20
|
+
logWarning(message);
|
|
15
21
|
}
|
package/utils/files.js
CHANGED
|
@@ -20,9 +20,38 @@ async function createIndex(dest) {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
async function hasSameContent(path1, path2) {
|
|
24
|
+
if (!fse.existsSync(path1) || !fse.existsSync(path2)) return false;
|
|
25
|
+
const [content1, content2] = await Promise.all([fse.readFile(path1), fse.readFile(path2)]);
|
|
26
|
+
return Buffer.compare(content1, content2) === 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function moveFileIfExists(src, dest) {
|
|
30
|
+
if (!fse.existsSync(src)) return Promise.resolve();
|
|
31
|
+
return fse.move(src, dest, { overwrite: true });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function manageCss({ type, dest }) {
|
|
35
|
+
const serverOutput = `${dest}/src/index.css`;
|
|
36
|
+
const clientOutput = `${dest}/src/main.css`;
|
|
37
|
+
const hooksOutput = `${dest}/src/hooks.css`;
|
|
38
|
+
|
|
39
|
+
const cssDest = type.toLowerCase() === 'webapp' ? `${dest}/src/css` : `${dest}/src/resource/client`;
|
|
40
|
+
|
|
41
|
+
if (await hasSameContent(serverOutput, clientOutput)) {
|
|
42
|
+
await fse.remove(serverOutput);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return Promise.all([
|
|
46
|
+
moveFileIfExists(serverOutput, `${cssDest}/index.css`),
|
|
47
|
+
moveFileIfExists(clientOutput, `${cssDest}/main.css`),
|
|
48
|
+
moveFileIfExists(hooksOutput, `${cssDest}/hooks.css`),
|
|
49
|
+
]);
|
|
50
|
+
}
|
|
51
|
+
|
|
23
52
|
export default function files({ type, dest }) {
|
|
24
|
-
if (type.toLowerCase() === 'restapp') return
|
|
53
|
+
if (type.toLowerCase() === 'restapp') return manageCss({ type, dest });
|
|
25
54
|
return () => Promise.all(
|
|
26
|
-
[createMain(dest), createIndex(dest)],
|
|
55
|
+
[createMain(dest), createIndex(dest), manageCss({ type, dest })],
|
|
27
56
|
);
|
|
28
57
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { transform } from 'rollup-plugin-insert';
|
|
2
|
-
import { existsSync } from 'fs';
|
|
3
|
-
import slash from 'slash';
|
|
4
|
-
import { relative, dirname } from 'path';
|
|
5
|
-
|
|
6
|
-
export default function getInsertPlugin({ input, imports }) {
|
|
7
|
-
return transform((ms, code) => {
|
|
8
|
-
const existingImports = imports
|
|
9
|
-
.filter((importee) => importee && existsSync(importee))
|
|
10
|
-
.map((importee) => slash(relative(dirname(input), importee)))
|
|
11
|
-
.map((importee) => `import './${importee}';`);
|
|
12
|
-
return `${existingImports.join('\n')}\n${code}`;
|
|
13
|
-
}, { include: input });
|
|
14
|
-
}
|
package/rollup/utils/moveCss.js
DELETED