@videinfra/static-website-builder 2.0.2 → 2.0.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.
- package/.prettierrc +11 -11
- package/CHANGELOG.md +214 -210
- package/README.md +102 -102
- package/bin/builder.js +40 -40
- package/eslint.config.js +39 -39
- package/gulpfile.js +63 -63
- package/init/default/config/config.js +44 -44
- package/init/default/src/html/data/global.js +9 -9
- package/init/default/src/javascripts/_entries.js +14 -14
- package/init/index.js +63 -63
- package/init/test/.env +6 -6
- package/init/test/.env.local +3 -2
- package/init/test/config/config.js +71 -67
- package/init/test/src/html/404.twig +12 -12
- package/init/test/src/html/data/global.js +10 -10
- package/init/test/src/html/env.twig +21 -21
- package/init/test/src/html/layouts/base.twig +1 -1
- package/init/test/src/html/other.twig +9 -9
- package/init/test/src/html/preposition.twig +4 -4
- package/init/test/src/javascripts/_entries-alt.js +10 -10
- package/init/test/src/javascripts/_entries.js +19 -19
- package/init/test/src/javascripts/common.js +13 -13
- package/init/test/src/javascripts/main.js +8 -8
- package/init/test/src/javascripts/something.ts +9 -9
- package/init/test/src/stylesheets/autoprefixer-test.scss +3 -3
- package/init/test/src/stylesheets/env-test.scss +28 -28
- package/init/test/src/stylesheets/ignore-test.scss +4 -4
- package/init/test/src/stylesheets/nested-calc-test.scss +3 -3
- package/init/test/src/stylesheets/sub-folder/import-test.scss +2 -2
- package/lib/camelize-file-name.js +21 -21
- package/lib/generate-gulp-tasks.js +85 -85
- package/lib/get-config.js +203 -204
- package/lib/get-file-names.js +23 -23
- package/lib/get-path.js +102 -102
- package/lib/globs-helper.js +243 -243
- package/lib/gulp/dynamic-task.js +8 -8
- package/lib/gulp/resolve-dynamic-task.js +11 -11
- package/lib/gulp/task-before-dest.js +8 -8
- package/lib/gulp/task-end.js +10 -10
- package/lib/gulp/task-start.js +12 -12
- package/lib/gulp/task-watch.js +66 -66
- package/lib/init/copy-folder.js +50 -50
- package/lib/init/folder-exists.js +10 -10
- package/lib/init/get-folder-list.js +16 -16
- package/lib/init/merge-package.js +17 -17
- package/lib/init/read-package.js +17 -17
- package/lib/log-error.js +15 -15
- package/lib/merge.js +27 -27
- package/lib/run-preprocess.js +32 -32
- package/lib/task-order.js +19 -19
- package/package.json +68 -68
- package/plugins/example/preprocess-config.js +17 -17
- package/plugins/example/task.js +55 -55
- package/plugins/example.js +38 -38
- package/plugins/sass-engine/preprocess-config.js +59 -59
- package/plugins/sass.js +41 -41
- package/plugins/twig/lodash-filters/filters.js +91 -91
- package/plugins/twig/lodash-filters.js +14 -14
- package/plugins/twig/symfony-filters/filters.js +102 -102
- package/plugins/twig/symfony-filters/preposition_nbsp.js +77 -77
- package/plugins/twig/symfony-filters.js +14 -14
- package/plugins/twig/symfony-functions/functions.js +31 -31
- package/plugins/twig/symfony-functions.js +14 -14
- package/plugins/twig-engine/preprocess-config.js +53 -53
- package/plugins/twig.js +74 -74
- package/tasks/browser-sync/config.js +39 -39
- package/tasks/browser-sync/preprocess-config.js +32 -32
- package/tasks/browser-sync/task.js +9 -9
- package/tasks/clean/config.js +20 -20
- package/tasks/clean/preprocess-config.js +19 -19
- package/tasks/clean/task.js +7 -7
- package/tasks/data/config.js +34 -34
- package/tasks/data/data-loader-js.js +14 -14
- package/tasks/data/data-loader-json.js +5 -5
- package/tasks/data/get-data.js +96 -96
- package/tasks/env/config.js +26 -23
- package/tasks/env/get-env.js +113 -81
- package/tasks/fonts/config.js +24 -24
- package/tasks/fonts/task.js +47 -47
- package/tasks/global/config.js +7 -7
- package/tasks/html/config.js +42 -42
- package/tasks/html/task.js +91 -91
- package/tasks/icons/config.js +47 -47
- package/tasks/icons/preprocess-config.js +60 -60
- package/tasks/icons/task.js +56 -56
- package/tasks/images/config.js +27 -27
- package/tasks/images/task.js +46 -46
- package/tasks/javascripts/config.js +69 -69
- package/tasks/javascripts/preprocess-config.js +109 -109
- package/tasks/javascripts/task.js +86 -86
- package/tasks/sitemap/config.js +48 -48
- package/tasks/sitemap/preprocess-config.js +18 -18
- package/tasks/sitemap/task.js +69 -69
- package/tasks/sizereport/config.js +23 -23
- package/tasks/sizereport/task.js +16 -16
- package/tasks/static/config.js +27 -27
- package/tasks/static/task.js +46 -46
- package/tasks/stylesheets/config.js +85 -85
- package/tasks/stylesheets/preprocess-config.js +41 -41
- package/tasks/stylesheets/task.js +73 -73
- package/tests/build/build.test.js +153 -153
- package/tests/camelize-file-name.test.js +11 -11
- package/tests/generate-gulp-tasks.test.js +78 -78
- package/tests/glob-helper.test.js +99 -99
- package/tests/merge.test.js +10 -10
- package/tests/preposition_nbsp.test.js +50 -50
- package/tests/run-preprocess.test.js +90 -90
- package/tests/sass-stringify.test.js +24 -24
- package/tests/sitemap.test.js +12 -12
- package/vendor/gulp-rolldown/index.js +151 -151
- package/vendor/gulp-rolldown/plugin-raw.js +17 -17
- package/vendor/gulp-rolldown/plugin-virtual-entry.js +30 -30
- package/vendor/gulp-sass/CHANGELOG.md +168 -168
- package/vendor/gulp-sass/LICENSE +20 -20
- package/vendor/gulp-sass/README.md +187 -187
- package/vendor/gulp-sass/index.js +208 -208
- package/vendor/gulp-sass/package.json +61 -61
- package/vendor/gulp-sass/sass-stringify.js +32 -32
- package/vendor/gulp-twig/LICENSE +20 -20
- package/vendor/gulp-twig/README.md +167 -167
- package/vendor/gulp-twig/index.js +138 -138
- package/vendor/gulp-twig/package.json +44 -44
package/tasks/icons/task.js
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import gulp from 'gulp';
|
|
2
|
-
import gulpif from 'gulp-if';
|
|
3
|
-
import svgstore from 'gulp-svgstore';
|
|
4
|
-
import svgmin from 'gulp-svgmin';
|
|
5
|
-
import nanomemoize from 'nano-memoize';
|
|
6
|
-
|
|
7
|
-
import globs from './../../lib/globs-helper.js';
|
|
8
|
-
import { getSourcePaths, getDestPath } from './../../lib/get-path.js';
|
|
9
|
-
import { getTaskConfig } from './../../lib/get-config.js';
|
|
10
|
-
|
|
11
|
-
import taskStart from '../../lib/gulp/task-start.js';
|
|
12
|
-
import taskEnd from '../../lib/gulp/task-end.js';
|
|
13
|
-
import taskBeforeDest from '../../lib/gulp/task-before-dest.js';
|
|
14
|
-
import taskWatch from '../../lib/gulp/task-watch.js';
|
|
15
|
-
|
|
16
|
-
const getWatchGlobPaths = function (forChokidar = false) {
|
|
17
|
-
const sourcePaths = getSourcePaths('icons');
|
|
18
|
-
const extensions = getTaskConfig('icons', 'extensions');
|
|
19
|
-
const ignore = getTaskConfig('icons', 'ignore');
|
|
20
|
-
|
|
21
|
-
return globs.generate(
|
|
22
|
-
globs.paths(sourcePaths).filesWithExtensions(extensions), // Files to watch
|
|
23
|
-
globs.paths(sourcePaths).paths(ignore).ignore(), // List of files which to ignore
|
|
24
|
-
forChokidar,
|
|
25
|
-
);
|
|
26
|
-
};
|
|
27
|
-
const getGlobPaths = nanomemoize.nanomemoize(function () {
|
|
28
|
-
return getWatchGlobPaths(false);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
function icons() {
|
|
32
|
-
return (
|
|
33
|
-
gulp
|
|
34
|
-
.src(getGlobPaths())
|
|
35
|
-
.pipe(taskStart())
|
|
36
|
-
|
|
37
|
-
// Minify SVG
|
|
38
|
-
.pipe(gulpif(!!getTaskConfig('icons', 'svgmin'), svgmin(getTaskConfig('icons', 'svgmin'))))
|
|
39
|
-
|
|
40
|
-
// Create sprite
|
|
41
|
-
.pipe(svgstore(getTaskConfig('icons', 'svgstore')))
|
|
42
|
-
|
|
43
|
-
.pipe(taskBeforeDest())
|
|
44
|
-
.pipe(gulp.dest(getDestPath('icons')))
|
|
45
|
-
|
|
46
|
-
// Reload on change
|
|
47
|
-
.pipe(taskEnd())
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function iconsWatch() {
|
|
52
|
-
return taskWatch(getWatchGlobPaths(true), icons);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const build = icons;
|
|
56
|
-
export const watch = iconsWatch;
|
|
1
|
+
import gulp from 'gulp';
|
|
2
|
+
import gulpif from 'gulp-if';
|
|
3
|
+
import svgstore from 'gulp-svgstore';
|
|
4
|
+
import svgmin from 'gulp-svgmin';
|
|
5
|
+
import nanomemoize from 'nano-memoize';
|
|
6
|
+
|
|
7
|
+
import globs from './../../lib/globs-helper.js';
|
|
8
|
+
import { getSourcePaths, getDestPath } from './../../lib/get-path.js';
|
|
9
|
+
import { getTaskConfig } from './../../lib/get-config.js';
|
|
10
|
+
|
|
11
|
+
import taskStart from '../../lib/gulp/task-start.js';
|
|
12
|
+
import taskEnd from '../../lib/gulp/task-end.js';
|
|
13
|
+
import taskBeforeDest from '../../lib/gulp/task-before-dest.js';
|
|
14
|
+
import taskWatch from '../../lib/gulp/task-watch.js';
|
|
15
|
+
|
|
16
|
+
const getWatchGlobPaths = function (forChokidar = false) {
|
|
17
|
+
const sourcePaths = getSourcePaths('icons');
|
|
18
|
+
const extensions = getTaskConfig('icons', 'extensions');
|
|
19
|
+
const ignore = getTaskConfig('icons', 'ignore');
|
|
20
|
+
|
|
21
|
+
return globs.generate(
|
|
22
|
+
globs.paths(sourcePaths).filesWithExtensions(extensions), // Files to watch
|
|
23
|
+
globs.paths(sourcePaths).paths(ignore).ignore(), // List of files which to ignore
|
|
24
|
+
forChokidar,
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
const getGlobPaths = nanomemoize.nanomemoize(function () {
|
|
28
|
+
return getWatchGlobPaths(false);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
function icons() {
|
|
32
|
+
return (
|
|
33
|
+
gulp
|
|
34
|
+
.src(getGlobPaths())
|
|
35
|
+
.pipe(taskStart())
|
|
36
|
+
|
|
37
|
+
// Minify SVG
|
|
38
|
+
.pipe(gulpif(!!getTaskConfig('icons', 'svgmin'), svgmin(getTaskConfig('icons', 'svgmin'))))
|
|
39
|
+
|
|
40
|
+
// Create sprite
|
|
41
|
+
.pipe(svgstore(getTaskConfig('icons', 'svgstore')))
|
|
42
|
+
|
|
43
|
+
.pipe(taskBeforeDest())
|
|
44
|
+
.pipe(gulp.dest(getDestPath('icons')))
|
|
45
|
+
|
|
46
|
+
// Reload on change
|
|
47
|
+
.pipe(taskEnd())
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function iconsWatch() {
|
|
52
|
+
return taskWatch(getWatchGlobPaths(true), icons);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const build = icons;
|
|
56
|
+
export const watch = iconsWatch;
|
package/tasks/images/config.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import * as imageTask from './task.js';
|
|
2
|
-
|
|
3
|
-
export const images = {
|
|
4
|
-
// Glob list of files, which to ignore, relative to the image source folder
|
|
5
|
-
// see https://gulpjs.com/docs/en/getting-started/explaining-globs/
|
|
6
|
-
ignore: [],
|
|
7
|
-
|
|
8
|
-
// Production only settings, overwrites default settings
|
|
9
|
-
production: {},
|
|
10
|
-
|
|
11
|
-
// Development only settings, overwrites default settings
|
|
12
|
-
development: {},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const tasks = {
|
|
16
|
-
images: [imageTask],
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Paths relative to the global src and dest folders
|
|
21
|
-
*/
|
|
22
|
-
export const paths = {
|
|
23
|
-
images: {
|
|
24
|
-
src: 'images',
|
|
25
|
-
dest: 'assets/images',
|
|
26
|
-
},
|
|
27
|
-
};
|
|
1
|
+
import * as imageTask from './task.js';
|
|
2
|
+
|
|
3
|
+
export const images = {
|
|
4
|
+
// Glob list of files, which to ignore, relative to the image source folder
|
|
5
|
+
// see https://gulpjs.com/docs/en/getting-started/explaining-globs/
|
|
6
|
+
ignore: [],
|
|
7
|
+
|
|
8
|
+
// Production only settings, overwrites default settings
|
|
9
|
+
production: {},
|
|
10
|
+
|
|
11
|
+
// Development only settings, overwrites default settings
|
|
12
|
+
development: {},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const tasks = {
|
|
16
|
+
images: [imageTask],
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Paths relative to the global src and dest folders
|
|
21
|
+
*/
|
|
22
|
+
export const paths = {
|
|
23
|
+
images: {
|
|
24
|
+
src: 'images',
|
|
25
|
+
dest: 'assets/images',
|
|
26
|
+
},
|
|
27
|
+
};
|
package/tasks/images/task.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import gulp from 'gulp';
|
|
2
|
-
import nanomemoize from 'nano-memoize';
|
|
3
|
-
|
|
4
|
-
import globs from './../../lib/globs-helper.js';
|
|
5
|
-
import { getSourcePaths, getDestPath } from './../../lib/get-path.js';
|
|
6
|
-
import { getTaskConfig } from './../../lib/get-config.js';
|
|
7
|
-
|
|
8
|
-
import taskStart from '../../lib/gulp/task-start.js';
|
|
9
|
-
import taskEnd from '../../lib/gulp/task-end.js';
|
|
10
|
-
import taskBeforeDest from '../../lib/gulp/task-before-dest.js';
|
|
11
|
-
import taskWatch from '../../lib/gulp/task-watch.js';
|
|
12
|
-
|
|
13
|
-
const getWatchGlobPaths = function (forChokidar = false) {
|
|
14
|
-
const sourcePaths = getSourcePaths('images');
|
|
15
|
-
const ignore = getTaskConfig('images', 'ignore');
|
|
16
|
-
|
|
17
|
-
return globs.generate(
|
|
18
|
-
globs.paths(sourcePaths).allFiles(), // Files to watch
|
|
19
|
-
globs.paths(sourcePaths).paths(ignore).ignore(), // List of files which to ignore
|
|
20
|
-
forChokidar,
|
|
21
|
-
);
|
|
22
|
-
};
|
|
23
|
-
const getGlobPaths = nanomemoize.nanomemoize(function () {
|
|
24
|
-
return getWatchGlobPaths(false);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
function images() {
|
|
28
|
-
return (
|
|
29
|
-
gulp
|
|
30
|
-
.src(getGlobPaths(), { since: gulp.lastRun(images) })
|
|
31
|
-
.pipe(taskStart())
|
|
32
|
-
|
|
33
|
-
.pipe(taskBeforeDest())
|
|
34
|
-
.pipe(gulp.dest(getDestPath('images')))
|
|
35
|
-
|
|
36
|
-
// Reload on change
|
|
37
|
-
.pipe(taskEnd())
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function imagesWatch() {
|
|
42
|
-
return taskWatch(getWatchGlobPaths(true), images);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export const build = images;
|
|
46
|
-
export const watch = imagesWatch;
|
|
1
|
+
import gulp from 'gulp';
|
|
2
|
+
import nanomemoize from 'nano-memoize';
|
|
3
|
+
|
|
4
|
+
import globs from './../../lib/globs-helper.js';
|
|
5
|
+
import { getSourcePaths, getDestPath } from './../../lib/get-path.js';
|
|
6
|
+
import { getTaskConfig } from './../../lib/get-config.js';
|
|
7
|
+
|
|
8
|
+
import taskStart from '../../lib/gulp/task-start.js';
|
|
9
|
+
import taskEnd from '../../lib/gulp/task-end.js';
|
|
10
|
+
import taskBeforeDest from '../../lib/gulp/task-before-dest.js';
|
|
11
|
+
import taskWatch from '../../lib/gulp/task-watch.js';
|
|
12
|
+
|
|
13
|
+
const getWatchGlobPaths = function (forChokidar = false) {
|
|
14
|
+
const sourcePaths = getSourcePaths('images');
|
|
15
|
+
const ignore = getTaskConfig('images', 'ignore');
|
|
16
|
+
|
|
17
|
+
return globs.generate(
|
|
18
|
+
globs.paths(sourcePaths).allFiles(), // Files to watch
|
|
19
|
+
globs.paths(sourcePaths).paths(ignore).ignore(), // List of files which to ignore
|
|
20
|
+
forChokidar,
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
const getGlobPaths = nanomemoize.nanomemoize(function () {
|
|
24
|
+
return getWatchGlobPaths(false);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
function images() {
|
|
28
|
+
return (
|
|
29
|
+
gulp
|
|
30
|
+
.src(getGlobPaths(), { since: gulp.lastRun(images) })
|
|
31
|
+
.pipe(taskStart())
|
|
32
|
+
|
|
33
|
+
.pipe(taskBeforeDest())
|
|
34
|
+
.pipe(gulp.dest(getDestPath('images')))
|
|
35
|
+
|
|
36
|
+
// Reload on change
|
|
37
|
+
.pipe(taskEnd())
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function imagesWatch() {
|
|
42
|
+
return taskWatch(getWatchGlobPaths(true), images);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const build = images;
|
|
46
|
+
export const watch = imagesWatch;
|
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
import * as preprocessJavascriptsConfig from './preprocess-config.js';
|
|
2
|
-
import * as javascriptsTask from './task.js';
|
|
3
|
-
|
|
4
|
-
export const javascripts = {
|
|
5
|
-
// JS file extensions
|
|
6
|
-
extensions: ['js', 'ts', 'tsx', 'jsx', 'json'],
|
|
7
|
-
|
|
8
|
-
// Instead of 'entry' we provide filename which list all entries
|
|
9
|
-
// Can be either an object or array of object to have multiple rolldown
|
|
10
|
-
// builds, one for each of the entry list files
|
|
11
|
-
entryList: {
|
|
12
|
-
// Path to the entry list file
|
|
13
|
-
name: '_entries.js',
|
|
14
|
-
|
|
15
|
-
// Entry shared chunk name, creates a share chunk if needed
|
|
16
|
-
shared: 'shared',
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
rolldown: {
|
|
20
|
-
// Sets the target environment for the generated JavaScript
|
|
21
|
-
// transform: '...',
|
|
22
|
-
|
|
23
|
-
// Input files, set from entries in preprocess-config.js
|
|
24
|
-
// input: {},
|
|
25
|
-
|
|
26
|
-
output: {
|
|
27
|
-
// format: 'esm',
|
|
28
|
-
dir: './[folder]',
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
// Production only settings, overwrites default settings
|
|
33
|
-
production: {
|
|
34
|
-
rolldown: {
|
|
35
|
-
output: {
|
|
36
|
-
sourcemap: 'hidden',
|
|
37
|
-
minify: true,
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
// Development only settings, overwrites default settings
|
|
43
|
-
development: {
|
|
44
|
-
rolldown: {
|
|
45
|
-
output: {
|
|
46
|
-
sourcemap: true,
|
|
47
|
-
minify: 'dce-only',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const preprocess = {
|
|
54
|
-
javascripts: [preprocessJavascriptsConfig],
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export const tasks = {
|
|
58
|
-
javascripts: [javascriptsTask],
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Paths relative to the global src and dest folders
|
|
63
|
-
*/
|
|
64
|
-
export const paths = {
|
|
65
|
-
javascripts: {
|
|
66
|
-
src: 'javascripts',
|
|
67
|
-
dest: 'assets/javascripts',
|
|
68
|
-
},
|
|
69
|
-
};
|
|
1
|
+
import * as preprocessJavascriptsConfig from './preprocess-config.js';
|
|
2
|
+
import * as javascriptsTask from './task.js';
|
|
3
|
+
|
|
4
|
+
export const javascripts = {
|
|
5
|
+
// JS file extensions
|
|
6
|
+
extensions: ['js', 'ts', 'tsx', 'jsx', 'json'],
|
|
7
|
+
|
|
8
|
+
// Instead of 'entry' we provide filename which list all entries
|
|
9
|
+
// Can be either an object or array of object to have multiple rolldown
|
|
10
|
+
// builds, one for each of the entry list files
|
|
11
|
+
entryList: {
|
|
12
|
+
// Path to the entry list file
|
|
13
|
+
name: '_entries.js',
|
|
14
|
+
|
|
15
|
+
// Entry shared chunk name, creates a share chunk if needed
|
|
16
|
+
shared: 'shared',
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
rolldown: {
|
|
20
|
+
// Sets the target environment for the generated JavaScript
|
|
21
|
+
// transform: '...',
|
|
22
|
+
|
|
23
|
+
// Input files, set from entries in preprocess-config.js
|
|
24
|
+
// input: {},
|
|
25
|
+
|
|
26
|
+
output: {
|
|
27
|
+
// format: 'esm',
|
|
28
|
+
dir: './[folder]',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
// Production only settings, overwrites default settings
|
|
33
|
+
production: {
|
|
34
|
+
rolldown: {
|
|
35
|
+
output: {
|
|
36
|
+
sourcemap: 'hidden',
|
|
37
|
+
minify: true,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
// Development only settings, overwrites default settings
|
|
43
|
+
development: {
|
|
44
|
+
rolldown: {
|
|
45
|
+
output: {
|
|
46
|
+
sourcemap: true,
|
|
47
|
+
minify: 'dce-only',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const preprocess = {
|
|
54
|
+
javascripts: [preprocessJavascriptsConfig],
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const tasks = {
|
|
58
|
+
javascripts: [javascriptsTask],
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Paths relative to the global src and dest folders
|
|
63
|
+
*/
|
|
64
|
+
export const paths = {
|
|
65
|
+
javascripts: {
|
|
66
|
+
src: 'javascripts',
|
|
67
|
+
dest: 'assets/javascripts',
|
|
68
|
+
},
|
|
69
|
+
};
|
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
import { getDestPath, getBuilderPath, getProjectPath, getSourcePath } from '../../lib/get-path.js';
|
|
2
|
-
import merge from '../../lib/merge.js';
|
|
3
|
-
import getEnvData, { loadEnvData } from '../env/get-env.js';
|
|
4
|
-
import get from 'lodash/get.js';
|
|
5
|
-
import cloneDeep from 'lodash/cloneDeep.js';
|
|
6
|
-
import replace from '@rollup/plugin-replace';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Modify configuration
|
|
10
|
-
*
|
|
11
|
-
* @param {object} config Javascript configuration
|
|
12
|
-
* @param {object} fullConfig Full configuration
|
|
13
|
-
* @returns {object} Transformed javascript configuration
|
|
14
|
-
*/
|
|
15
|
-
export default function preprocessJavascriptsConfig(config, fullConfig) {
|
|
16
|
-
let entryList = config.entryList;
|
|
17
|
-
|
|
18
|
-
// User may specify a function, execute it to get object / array
|
|
19
|
-
if (typeof entryList === 'function') {
|
|
20
|
-
entryList = entryList(config);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// User may specify multiple entry list files, convert to array
|
|
24
|
-
if (!Array.isArray(entryList)) {
|
|
25
|
-
entryList = [entryList];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// User may specify only a name of the entry file
|
|
29
|
-
// Set shared chunk name for each of the entry files
|
|
30
|
-
// Each entryList item is { name: '...', shared?: '...', outpuSubFolder?: '...' }
|
|
31
|
-
entryList = entryList.map((entry, index) => {
|
|
32
|
-
return {
|
|
33
|
-
name: typeof entry === 'string' ? entry : entry.name,
|
|
34
|
-
shared: typeof entry !== 'string' && entry && entry.shared ? entry.shared : index === 0 ? 'shared' : '',
|
|
35
|
-
outpuSubFolder: typeof entry !== 'string' && entry && entry.outpuSubFolder ? entry.outpuSubFolder : '',
|
|
36
|
-
};
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
return entryList.map((entry) => {
|
|
40
|
-
const entryConfig = cloneDeep(config);
|
|
41
|
-
entryConfig.rolldown = Object.assign({}, entryConfig.rolldown);
|
|
42
|
-
|
|
43
|
-
// Output paths
|
|
44
|
-
const output = merge({}, get(entryConfig, ['rolldown', 'output'], null));
|
|
45
|
-
|
|
46
|
-
output.dir = output.dir.replace('[folder]/', entry.outpuSubFolder ? entry.outpuSubFolder + '/' : '').replace('[folder]', entry.outpuSubFolder ? entry.outpuSubFolder : '');
|
|
47
|
-
|
|
48
|
-
output.dir = getDestPath('javascripts', output.dir);
|
|
49
|
-
|
|
50
|
-
// Use process.env... variables from .env files
|
|
51
|
-
const envVariables = merge(getEnvData().js, {
|
|
52
|
-
'process.env.NODE_ENV': JSON.stringify(global.production ? 'production' : 'development'),
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// Rewrite shared.js and rolldown-runtime.js to include cache busting asset version so that we could
|
|
56
|
-
// preload those assets using <link rel="preload" as="script" href="{{ asset(...) }}" />
|
|
57
|
-
const envData = loadEnvData();
|
|
58
|
-
const assetVersion = envData['ASSETS_VERSION'];
|
|
59
|
-
const replacements = {};
|
|
60
|
-
|
|
61
|
-
if (assetVersion) {
|
|
62
|
-
replacements['/rolldown-runtime.js'] = `/rolldown-runtime.js?v=${assetVersion}`;
|
|
63
|
-
|
|
64
|
-
if (entry.shared) {
|
|
65
|
-
replacements[`/${entry.shared}.js`] = `/${entry.shared}.js?v=${assetVersion}`;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const buildConfig = merge(entryConfig, {
|
|
70
|
-
rolldown: {
|
|
71
|
-
// Entries, this file is resolved by gulp-rolldown and converted into
|
|
72
|
-
// `inputs` option
|
|
73
|
-
entries: entry,
|
|
74
|
-
|
|
75
|
-
plugins: [
|
|
76
|
-
replace({
|
|
77
|
-
preventAssignment: true,
|
|
78
|
-
...envVariables,
|
|
79
|
-
...replacements,
|
|
80
|
-
}),
|
|
81
|
-
],
|
|
82
|
-
|
|
83
|
-
// Output folder
|
|
84
|
-
output: output,
|
|
85
|
-
|
|
86
|
-
// Imports
|
|
87
|
-
resolve: merge(
|
|
88
|
-
{
|
|
89
|
-
// File extensions
|
|
90
|
-
extensions: entryConfig.extensions.map((extension) => `.${extension}`),
|
|
91
|
-
|
|
92
|
-
// Import folders
|
|
93
|
-
modules: [
|
|
94
|
-
// Allow imports from node_modules
|
|
95
|
-
getBuilderPath('node_modules'),
|
|
96
|
-
getProjectPath('node_modules'),
|
|
97
|
-
|
|
98
|
-
// Allow imports from source folder
|
|
99
|
-
getSourcePath('javascripts'),
|
|
100
|
-
],
|
|
101
|
-
},
|
|
102
|
-
get(entryConfig, ['rolldown', 'resolve'], {}),
|
|
103
|
-
),
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
return buildConfig;
|
|
108
|
-
});
|
|
109
|
-
}
|
|
1
|
+
import { getDestPath, getBuilderPath, getProjectPath, getSourcePath } from '../../lib/get-path.js';
|
|
2
|
+
import merge from '../../lib/merge.js';
|
|
3
|
+
import getEnvData, { loadEnvData } from '../env/get-env.js';
|
|
4
|
+
import get from 'lodash/get.js';
|
|
5
|
+
import cloneDeep from 'lodash/cloneDeep.js';
|
|
6
|
+
import replace from '@rollup/plugin-replace';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Modify configuration
|
|
10
|
+
*
|
|
11
|
+
* @param {object} config Javascript configuration
|
|
12
|
+
* @param {object} fullConfig Full configuration
|
|
13
|
+
* @returns {object} Transformed javascript configuration
|
|
14
|
+
*/
|
|
15
|
+
export default function preprocessJavascriptsConfig(config, fullConfig) {
|
|
16
|
+
let entryList = config.entryList;
|
|
17
|
+
|
|
18
|
+
// User may specify a function, execute it to get object / array
|
|
19
|
+
if (typeof entryList === 'function') {
|
|
20
|
+
entryList = entryList(config);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// User may specify multiple entry list files, convert to array
|
|
24
|
+
if (!Array.isArray(entryList)) {
|
|
25
|
+
entryList = [entryList];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// User may specify only a name of the entry file
|
|
29
|
+
// Set shared chunk name for each of the entry files
|
|
30
|
+
// Each entryList item is { name: '...', shared?: '...', outpuSubFolder?: '...' }
|
|
31
|
+
entryList = entryList.map((entry, index) => {
|
|
32
|
+
return {
|
|
33
|
+
name: typeof entry === 'string' ? entry : entry.name,
|
|
34
|
+
shared: typeof entry !== 'string' && entry && entry.shared ? entry.shared : index === 0 ? 'shared' : '',
|
|
35
|
+
outpuSubFolder: typeof entry !== 'string' && entry && entry.outpuSubFolder ? entry.outpuSubFolder : '',
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return entryList.map((entry) => {
|
|
40
|
+
const entryConfig = cloneDeep(config);
|
|
41
|
+
entryConfig.rolldown = Object.assign({}, entryConfig.rolldown);
|
|
42
|
+
|
|
43
|
+
// Output paths
|
|
44
|
+
const output = merge({}, get(entryConfig, ['rolldown', 'output'], null));
|
|
45
|
+
|
|
46
|
+
output.dir = output.dir.replace('[folder]/', entry.outpuSubFolder ? entry.outpuSubFolder + '/' : '').replace('[folder]', entry.outpuSubFolder ? entry.outpuSubFolder : '');
|
|
47
|
+
|
|
48
|
+
output.dir = getDestPath('javascripts', output.dir);
|
|
49
|
+
|
|
50
|
+
// Use process.env... variables from .env files
|
|
51
|
+
const envVariables = merge(getEnvData().js, {
|
|
52
|
+
'process.env.NODE_ENV': JSON.stringify(global.production ? 'production' : 'development'),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Rewrite shared.js and rolldown-runtime.js to include cache busting asset version so that we could
|
|
56
|
+
// preload those assets using <link rel="preload" as="script" href="{{ asset(...) }}" />
|
|
57
|
+
const envData = loadEnvData();
|
|
58
|
+
const assetVersion = envData['ASSETS_VERSION'];
|
|
59
|
+
const replacements = {};
|
|
60
|
+
|
|
61
|
+
if (assetVersion) {
|
|
62
|
+
replacements['/rolldown-runtime.js'] = `/rolldown-runtime.js?v=${assetVersion}`;
|
|
63
|
+
|
|
64
|
+
if (entry.shared) {
|
|
65
|
+
replacements[`/${entry.shared}.js`] = `/${entry.shared}.js?v=${assetVersion}`;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const buildConfig = merge(entryConfig, {
|
|
70
|
+
rolldown: {
|
|
71
|
+
// Entries, this file is resolved by gulp-rolldown and converted into
|
|
72
|
+
// `inputs` option
|
|
73
|
+
entries: entry,
|
|
74
|
+
|
|
75
|
+
plugins: [
|
|
76
|
+
replace({
|
|
77
|
+
preventAssignment: true,
|
|
78
|
+
...envVariables,
|
|
79
|
+
...replacements,
|
|
80
|
+
}),
|
|
81
|
+
],
|
|
82
|
+
|
|
83
|
+
// Output folder
|
|
84
|
+
output: output,
|
|
85
|
+
|
|
86
|
+
// Imports
|
|
87
|
+
resolve: merge(
|
|
88
|
+
{
|
|
89
|
+
// File extensions
|
|
90
|
+
extensions: entryConfig.extensions.map((extension) => `.${extension}`),
|
|
91
|
+
|
|
92
|
+
// Import folders
|
|
93
|
+
modules: [
|
|
94
|
+
// Allow imports from node_modules
|
|
95
|
+
getBuilderPath('node_modules'),
|
|
96
|
+
getProjectPath('node_modules'),
|
|
97
|
+
|
|
98
|
+
// Allow imports from source folder
|
|
99
|
+
getSourcePath('javascripts'),
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
get(entryConfig, ['rolldown', 'resolve'], {}),
|
|
103
|
+
),
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
return buildConfig;
|
|
108
|
+
});
|
|
109
|
+
}
|