@videinfra/static-website-builder 1.12.1 → 1.13.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/CHANGELOG.md +4 -0
- package/init/test/config/config.js +13 -1
- package/init/test/src/javascripts/_entries-alt.js +13 -0
- package/package.json +1 -1
- package/tasks/javascripts/config.js +1 -1
- package/tasks/javascripts/preprocess-config.js +26 -18
- package/tests/build/build.test.js +22 -8
- package/vendor/webpack-stream/index.js +1 -9
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [1.13.0] - 2024-08-23
|
|
8
|
+
### Added
|
|
9
|
+
- Added 'outpuSubFolder' property to entries configuration
|
|
10
|
+
|
|
7
11
|
## [1.12.1] - 2024-08-19
|
|
8
12
|
### Added
|
|
9
13
|
- Version string to the dynamically loaded JS files
|
|
@@ -9,7 +9,19 @@ exports.data = {};
|
|
|
9
9
|
exports.fonts = {};
|
|
10
10
|
exports.icons = {};
|
|
11
11
|
exports.images = {};
|
|
12
|
-
exports.javascripts = {
|
|
12
|
+
exports.javascripts = {
|
|
13
|
+
entryList: [
|
|
14
|
+
{
|
|
15
|
+
name: '_entries.js',
|
|
16
|
+
shared: 'shared',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: '_entries-alt.js',
|
|
20
|
+
shared: 'shared',
|
|
21
|
+
outpuSubFolder: 'alt'
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
};
|
|
13
25
|
exports.stylesheets = {};
|
|
14
26
|
exports.sizereport = false;
|
|
15
27
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* All files listed in here are created / compiled and additionally
|
|
3
|
+
* shared.js is automatically created, which contains all common JS (chunks / modules imported from more than 1 entry files).
|
|
4
|
+
*/
|
|
5
|
+
module.exports = {
|
|
6
|
+
'shared': [
|
|
7
|
+
'./common'
|
|
8
|
+
],
|
|
9
|
+
'main': [
|
|
10
|
+
'./common',
|
|
11
|
+
'./main'
|
|
12
|
+
]
|
|
13
|
+
};
|
package/package.json
CHANGED
|
@@ -24,10 +24,10 @@ function requireUncached(module) {
|
|
|
24
24
|
* @returns {object} List of entry files
|
|
25
25
|
*/
|
|
26
26
|
function getEntry (config) {
|
|
27
|
-
const
|
|
27
|
+
const entryFileName = paths.getSourcePath('javascripts', config.entryList.name);
|
|
28
28
|
|
|
29
29
|
return function getEntries () {
|
|
30
|
-
return requireUncached(
|
|
30
|
+
return requireUncached(entryFileName);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -62,15 +62,26 @@ module.exports = function preprocessJavascriptsConfig (config, fullConfig) {
|
|
|
62
62
|
return {
|
|
63
63
|
name: typeof entry === 'string' ? entry : entry.name,
|
|
64
64
|
shared: typeof entry !== 'string' && entry && entry.shared ? entry.shared : (index === 0 ? 'shared' : ''),
|
|
65
|
+
outpuSubFolder: typeof entry !== 'string' && entry && entry.outpuSubFolder ? entry.outpuSubFolder : '',
|
|
65
66
|
};
|
|
66
67
|
});
|
|
67
68
|
|
|
68
|
-
return config.entryList.map((
|
|
69
|
-
const entryConfig =
|
|
69
|
+
return config.entryList.map((entry) => {
|
|
70
|
+
const entryConfig = cloneDeep(config);
|
|
70
71
|
entryConfig.webpack = Object.assign({}, entryConfig.webpack);
|
|
71
72
|
|
|
72
73
|
// One entry file per config
|
|
73
|
-
entryConfig.entryList =
|
|
74
|
+
entryConfig.entryList = entry;
|
|
75
|
+
|
|
76
|
+
// Output paths
|
|
77
|
+
const output = merge({
|
|
78
|
+
path: paths.getDestPath('javascripts'),
|
|
79
|
+
publicPath: paths.getPublicPath('javascripts'),
|
|
80
|
+
}, get(entryConfig, ['webpack', 'output'], null));
|
|
81
|
+
|
|
82
|
+
output.filename = output.filename
|
|
83
|
+
.replace('[folder]/', entry.outpuSubFolder ? entry.outpuSubFolder + '/' : '')
|
|
84
|
+
.replace('[folder]', entry.outpuSubFolder ? entry.outpuSubFolder : '');
|
|
74
85
|
|
|
75
86
|
const buildConfig = merge(entryConfig, {
|
|
76
87
|
webpack: {
|
|
@@ -81,10 +92,7 @@ module.exports = function preprocessJavascriptsConfig (config, fullConfig) {
|
|
|
81
92
|
entry: getEntry(entryConfig),
|
|
82
93
|
|
|
83
94
|
// Output folder
|
|
84
|
-
output:
|
|
85
|
-
path: paths.getDestPath('javascripts'),
|
|
86
|
-
publicPath: paths.getPublicPath('javascripts'),
|
|
87
|
-
}, get(entryConfig, ['webpack', 'output'], null)),
|
|
95
|
+
output: output,
|
|
88
96
|
|
|
89
97
|
// Plugins, add ENV variables
|
|
90
98
|
plugins: [
|
|
@@ -94,7 +102,7 @@ module.exports = function preprocessJavascriptsConfig (config, fullConfig) {
|
|
|
94
102
|
new WatchExternalFilesPlugin.default({
|
|
95
103
|
verbose: false,
|
|
96
104
|
files: [
|
|
97
|
-
paths.getSourcePath('javascripts',
|
|
105
|
+
paths.getSourcePath('javascripts', entry.name),
|
|
98
106
|
],
|
|
99
107
|
}),
|
|
100
108
|
new WebpackURLVersioningPlugin(),
|
|
@@ -128,16 +136,16 @@ module.exports = function preprocessJavascriptsConfig (config, fullConfig) {
|
|
|
128
136
|
|
|
129
137
|
// Add webpack.optimization.runtimeChunk and webpack.optimization.splitChunks,
|
|
130
138
|
// if entryConfig.shared doesn't exist, then remove them
|
|
131
|
-
if (
|
|
139
|
+
if (entry.shared && entry.shared !== 'shared') {
|
|
132
140
|
const optimization = buildConfig.webpack.optimization = cloneDeep(buildConfig.webpack.optimization || {});
|
|
133
141
|
|
|
134
142
|
if (get(optimization, ['runtimeChunk', 'name'], null) === 'shared') {
|
|
135
143
|
// Change shared runtimeChunk name
|
|
136
|
-
optimization.runtimeChunk.name =
|
|
144
|
+
optimization.runtimeChunk.name = entry.shared;
|
|
137
145
|
} else if (!optimization.runtimeChunk) {
|
|
138
146
|
// Add shared runtimeChunk
|
|
139
147
|
optimization.runtimeChunk = {
|
|
140
|
-
name:
|
|
148
|
+
name: entry.shared,
|
|
141
149
|
};
|
|
142
150
|
}
|
|
143
151
|
|
|
@@ -145,20 +153,20 @@ module.exports = function preprocessJavascriptsConfig (config, fullConfig) {
|
|
|
145
153
|
// Rename split chunks "shared" chunk
|
|
146
154
|
const cacheGroups = optimization.splitChunks.cacheGroups.shared;
|
|
147
155
|
delete(optimization.splitChunks.cacheGroups.shared);
|
|
148
|
-
optimization.splitChunks.cacheGroups[
|
|
149
|
-
cacheGroups.name =
|
|
156
|
+
optimization.splitChunks.cacheGroups[entry.shared] = cacheGroups;
|
|
157
|
+
cacheGroups.name = entry.shared;
|
|
150
158
|
} else if (!optimization.splitChunks) {
|
|
151
159
|
// Add splitChunks
|
|
152
160
|
optimization.splitChunks = optimization.splitChunks || {};
|
|
153
161
|
optimization.splitChunks.cacheGroups = optimization.splitChunks.cacheGroups || {};
|
|
154
|
-
optimization.splitChunks.cacheGroups[
|
|
155
|
-
name:
|
|
162
|
+
optimization.splitChunks.cacheGroups[entry.shared] = {
|
|
163
|
+
name: entry.shared,
|
|
156
164
|
chunks: 'all',
|
|
157
165
|
minChunks: 3,
|
|
158
166
|
enforce: true,
|
|
159
167
|
};
|
|
160
168
|
}
|
|
161
|
-
} else if (!
|
|
169
|
+
} else if (!entry.shared) {
|
|
162
170
|
// Remove optimization
|
|
163
171
|
delete(buildConfig.webpack.optimization);
|
|
164
172
|
}
|
|
@@ -35,7 +35,7 @@ test('SASS sub-folder import test', () => {
|
|
|
35
35
|
|
|
36
36
|
test('SASS autoprefixer test', () => {
|
|
37
37
|
return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/autoprefixer-test.css'), {'encoding': 'utf8'}).then((css) => {
|
|
38
|
-
expect(css).toBe('main{
|
|
38
|
+
expect(css).toBe('main{clip-path:polygon(0 0,100% 0,100% 100%,0 100%)}');
|
|
39
39
|
});
|
|
40
40
|
});
|
|
41
41
|
|
|
@@ -62,9 +62,25 @@ test('Font file fake not copied', () => {
|
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
test('shared.js file exists', () => {
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
return Promise.all([
|
|
66
|
+
fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/shared.js'), {'encoding': 'utf8'}).then((js) => {
|
|
67
|
+
expect(js.indexOf('console.log("Shared file loaded")')).not.toBe(-1);
|
|
68
|
+
}),
|
|
69
|
+
fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/alt/shared.js'), {'encoding': 'utf8'}).then((js) => {
|
|
70
|
+
expect(js.indexOf('console.log("Shared file loaded")')).not.toBe(-1);
|
|
71
|
+
}),
|
|
72
|
+
]);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('main.js file exists', () => {
|
|
76
|
+
return Promise.all([
|
|
77
|
+
fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/main.js'), {'encoding': 'utf8'}).then((js) => {
|
|
78
|
+
expect(js.indexOf('console.log("Hello from main page!")')).not.toBe(-1);
|
|
79
|
+
}),
|
|
80
|
+
fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/alt/main.js'), {'encoding': 'utf8'}).then((js) => {
|
|
81
|
+
expect(js.indexOf('console.log("Hello from main page!")')).not.toBe(-1);
|
|
82
|
+
}),
|
|
83
|
+
]);
|
|
68
84
|
});
|
|
69
85
|
|
|
70
86
|
test('other.js file exists', () => {
|
|
@@ -73,10 +89,8 @@ test('other.js file exists', () => {
|
|
|
73
89
|
});
|
|
74
90
|
});
|
|
75
91
|
|
|
76
|
-
test('
|
|
77
|
-
|
|
78
|
-
expect(js.indexOf('console.log("Hello from main page!")')).not.toBe(-1);
|
|
79
|
-
});
|
|
92
|
+
test('alt/other.js file doesn\'t exist', async () => {
|
|
93
|
+
expect(fsPromises.stat(path.resolve(publicPath, 'assets/javascripts/alt/other.js'))).rejects.toThrow();
|
|
80
94
|
});
|
|
81
95
|
|
|
82
96
|
test('icons generated', () => {
|
|
@@ -27,18 +27,10 @@ var defaultStatsOptions = {
|
|
|
27
27
|
errorDetails: false
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
var cache = {};
|
|
31
|
-
|
|
32
30
|
module.exports = function (options, wp, done) {
|
|
33
|
-
if (cache.wp !== wp || cache.options !== options) {
|
|
34
|
-
cache = {};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
cache.options = options;
|
|
38
|
-
cache.wp = wp;
|
|
39
|
-
|
|
40
31
|
options = clone(options) || {};
|
|
41
32
|
var config = options.config || options;
|
|
33
|
+
var cache = {};
|
|
42
34
|
|
|
43
35
|
// Webpack 4 doesn't support the `quiet` attribute, however supports
|
|
44
36
|
// setting `stats` to a string within an array of configurations
|