@soleil-se/build-app 1.2.2 → 1.3.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/config/index.js +1 -2
- package/index.js +2 -2
- package/package.json +2 -1
- package/rollup/api/getSveltePlugin.js +11 -5
- package/rollup/server.js +1 -1
- package/utils/copy.js +12 -8
package/config/index.js
CHANGED
|
@@ -5,8 +5,7 @@ import configFiles from '../utils/configFiles.js';
|
|
|
5
5
|
export default function config({ src, dest, cache, debug }) {
|
|
6
6
|
if (src) {
|
|
7
7
|
return [
|
|
8
|
-
copy({ src: `${src}/index.html`, dest }),
|
|
9
|
-
copy({ src: `${src}/config.css`, dest }),
|
|
8
|
+
copy({ src: [`${src}/index.html`, `${src}/config.css`], dest, deep: false }),
|
|
10
9
|
server({
|
|
11
10
|
input: `${src}/index.js`,
|
|
12
11
|
output: `${dest}/index.js`,
|
package/index.js
CHANGED
|
@@ -27,7 +27,7 @@ async function main() {
|
|
|
27
27
|
task('copy', [
|
|
28
28
|
copy({ src: './manifest.json', dest: './dist/src' }),
|
|
29
29
|
copy(manifest.bundled || (input.server || '').startsWith('./src')
|
|
30
|
-
? { src: ['./src/manifest.json', './src/appDataDefaults.json', './src/i18n', './src/config', './src/resource'], dest: './dist
|
|
30
|
+
? { src: ['./src/manifest.json', './src/appDataDefaults.json', './src/i18n/*.json', './src/config', './src/resource'], dest: './dist' }
|
|
31
31
|
: { src: ['./src'], dest: './dist' }),
|
|
32
32
|
]),
|
|
33
33
|
task('server', server({
|
|
@@ -82,7 +82,7 @@ async function main() {
|
|
|
82
82
|
} else {
|
|
83
83
|
await runTasks(tasks);
|
|
84
84
|
}
|
|
85
|
-
if (args.run) await runTasks(tasks);
|
|
85
|
+
if (args.build || args.run) await runTasks(tasks);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
main().catch((e) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soleil-se/build-app",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"bin": {
|
|
5
5
|
"build-app": "./bin/index.js",
|
|
6
6
|
"sv-app-build": "./bin/index.js"
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"find-up": "6.3.0",
|
|
32
32
|
"form-data": "4.0.0",
|
|
33
33
|
"fs-extra": "10.0.1",
|
|
34
|
+
"glob": "^7.2.0",
|
|
34
35
|
"got": "12.0.1",
|
|
35
36
|
"gzip-size": "7.0.0",
|
|
36
37
|
"lodash-es": "4.17.21",
|
|
@@ -19,11 +19,13 @@ const cssHash = ({ hash, css, name }) => {
|
|
|
19
19
|
return `${kebabCase(validClass)}-${hash(css)}`;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const getSvelteConfig = async () => {
|
|
23
23
|
const svelteConfigPath = findUpSync('svelte.config.js');
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
return svelteConfigPath ? import(`file://${svelteConfigPath}`).then((pkg) => pkg.default) : {};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const getPreprocess = async (svelteConfig) => {
|
|
28
|
+
if (svelteConfig.preprocess) return svelteConfig.preprocess;
|
|
27
29
|
const sveltePreprocess = await import('svelte-preprocess').then((pkg) => pkg.default);
|
|
28
30
|
return sveltePreprocess(preprocessOptions);
|
|
29
31
|
};
|
|
@@ -34,13 +36,17 @@ export default async function getSveltePlugin({
|
|
|
34
36
|
if (hasSvelte(input)) {
|
|
35
37
|
const svelte = await import('rollup-plugin-svelte').then((pkg) => pkg.default);
|
|
36
38
|
|
|
39
|
+
const svelteConfig = await getSvelteConfig();
|
|
40
|
+
|
|
37
41
|
return svelte({
|
|
38
|
-
preprocess: await getPreprocess(),
|
|
42
|
+
preprocess: await getPreprocess(svelteConfig),
|
|
39
43
|
emitCss,
|
|
40
44
|
compilerOptions: {
|
|
45
|
+
...svelteConfig.compilerOptions,
|
|
41
46
|
generate: ssr ? 'ssr' : 'dom',
|
|
42
47
|
hydratable,
|
|
43
48
|
dev: debug,
|
|
49
|
+
enableSourcemap: debug,
|
|
44
50
|
cssHash,
|
|
45
51
|
},
|
|
46
52
|
});
|
package/rollup/server.js
CHANGED
|
@@ -62,7 +62,7 @@ export default function rollupServer({
|
|
|
62
62
|
bundleCache = cache && bundle.cache;
|
|
63
63
|
await bundle.write({
|
|
64
64
|
file: output,
|
|
65
|
-
intro: 'var Promise = Promise || { resolve: () => {} };',
|
|
65
|
+
intro: 'var Promise = Promise || { resolve: () => {} }; var global = global || this; var self = global; var setTimeout = setTimeout || function(cb) { cb() };',
|
|
66
66
|
format: 'iife',
|
|
67
67
|
});
|
|
68
68
|
|
package/utils/copy.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import fse from 'fs-extra';
|
|
2
|
-
import {
|
|
2
|
+
import { resolve, join, basename } from 'path';
|
|
3
|
+
import glob from 'glob';
|
|
3
4
|
|
|
4
|
-
export default function copy({ src, dest }) {
|
|
5
|
-
const
|
|
5
|
+
export default function copy({ src, dest, deep = true }) {
|
|
6
|
+
const patterns = Array.isArray(src) ? src : [src];
|
|
6
7
|
|
|
7
|
-
return () =>
|
|
8
|
-
files.map((
|
|
9
|
-
|
|
10
|
-
)
|
|
11
|
-
|
|
8
|
+
return () => {
|
|
9
|
+
const files = patterns.map((pattern) => glob.sync(pattern)).flat();
|
|
10
|
+
|
|
11
|
+
return Promise.all(files.map((file) => {
|
|
12
|
+
const path = deep ? resolve(dest, file) : join(dest, basename(file));
|
|
13
|
+
return fse.copy(file, path);
|
|
14
|
+
}));
|
|
15
|
+
};
|
|
12
16
|
}
|