@videinfra/static-website-builder 2.2.0 → 2.2.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/CHANGELOG.md +4 -0
- package/init/test/config/config.js +1 -0
- package/init/test/src/html/env.twig +1 -0
- package/init/test/src/javascripts/main.js +1 -0
- package/init/test/src/stylesheets/env-test.scss +1 -0
- package/package.json +1 -1
- package/tasks/env/get-env.js +8 -10
- package/tests/build/build.test.js +0 -133
- package/tests/build/env.test.js +41 -0
- package/tests/build/js.test.js +43 -0
- package/tests/build/scss.test.js +53 -0
- package/tests/build/twig.test.js +23 -0
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
|
+
## [2.2.1] - 2026-03-12
|
|
8
|
+
### Fixed
|
|
9
|
+
- Fixed env variables not being set to empty string when not found
|
|
10
|
+
|
|
7
11
|
## [2.2.0] - 2026-03-06
|
|
8
12
|
### Changed
|
|
9
13
|
- Updated dependencies
|
|
@@ -6,3 +6,4 @@ console.log('env.bar ==', process.env.bar);
|
|
|
6
6
|
console.log('env.typeBoolTrue ==', process.env.typeBoolTrue);
|
|
7
7
|
console.log('env.typeBoolFalse ==', process.env.typeBoolFalse);
|
|
8
8
|
console.log('env.typeNumber ==', process.env.typeNumber);
|
|
9
|
+
console.log('env.nonExisting ==', process.env.nonExisting);
|
package/package.json
CHANGED
package/tasks/env/get-env.js
CHANGED
|
@@ -5,7 +5,7 @@ import { getPathConfig, getProjectPath } from '../../lib/get-path.js';
|
|
|
5
5
|
import { getTaskConfig } from '../../lib/get-config.js';
|
|
6
6
|
|
|
7
7
|
function escapeJSVariable(value) {
|
|
8
|
-
if (value === 'true' || value === 'false' || value === true || value === false || !isNaN(value)) {
|
|
8
|
+
if (value === 'true' || value === 'false' || value === true || value === false || (value !== '' && !isNaN(value))) {
|
|
9
9
|
return value;
|
|
10
10
|
} else {
|
|
11
11
|
// Convert to string
|
|
@@ -91,15 +91,13 @@ const getEnvData = nanomemoize.nanomemoize(function () {
|
|
|
91
91
|
const map = getTaskConfig('env', 'map');
|
|
92
92
|
|
|
93
93
|
Object.keys(map).forEach((key) => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
scssVariables.env[kebabCase] = value;
|
|
102
|
-
}
|
|
94
|
+
const value = key in envVariables ? envVariables[key] : '';
|
|
95
|
+
const camelCase = map[key];
|
|
96
|
+
const kebabCase = map[key];
|
|
97
|
+
twigVariables[camelCase] = normalizeTwigVariable(value);
|
|
98
|
+
envOutVariables[camelCase] = value;
|
|
99
|
+
jsVariables[`process.env.${camelCase}`] = escapeJSVariable(value);
|
|
100
|
+
scssVariables.env[kebabCase] = value;
|
|
103
101
|
});
|
|
104
102
|
|
|
105
103
|
return {
|
|
@@ -5,64 +5,6 @@ import fsPromises from 'fs/promises';
|
|
|
5
5
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
6
|
const publicPath = path.resolve(__dirname, 'public');
|
|
7
7
|
|
|
8
|
-
test('TWIG templates rendered and minified with JS and JSON data', () => {
|
|
9
|
-
return fsPromises.readFile(path.resolve(publicPath, 'index.html'), { encoding: 'utf8' }).then((html) => {
|
|
10
|
-
expect(html).toBe('<html><body><h1>Hello World!</h1></body></html>');
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test('Multiple TWIG templates rendered', () => {
|
|
15
|
-
expect.assertions(1);
|
|
16
|
-
return expect(fsPromises.access(path.resolve(publicPath, 'other.html'))).resolves.toBe(undefined);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test('SASS variable test', () => {
|
|
20
|
-
return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/variable-test.css'), { encoding: 'utf8' }).then((css) => {
|
|
21
|
-
expect(css.startsWith('main{background:#fff;color:#222}')).toBe(true);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test('SASS import test', () => {
|
|
26
|
-
return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/import-test.css'), { encoding: 'utf8' }).then((css) => {
|
|
27
|
-
expect(css.startsWith('.btn{background:#222;color:#fff}')).toBe(true);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test('SASS sub-folder import test', () => {
|
|
32
|
-
return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/sub-folder/import-test.css'), { encoding: 'utf8' }).then((css) => {
|
|
33
|
-
expect(css.startsWith('.btn{background:#222;color:#fff}')).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test('SASS autoprefixer test', () => {
|
|
38
|
-
return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/autoprefixer-test.css'), { encoding: 'utf8' }).then((css) => {
|
|
39
|
-
expect(css.startsWith('main{clip-path:polygon(0 0,100% 0,100% 100%,0 100%)}')).toBe(true);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('CSS nano ignore test', () => {
|
|
44
|
-
return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/ignore-test.css'), { encoding: 'utf8' }).then((css) => {
|
|
45
|
-
expect(css.startsWith(':root{--yes: ;--no:initial}')).toBe(true);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test('CSS nano nested calc test', () => {
|
|
50
|
-
return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/nested-calc-test.css'), { encoding: 'utf8' }).then((css) => {
|
|
51
|
-
expect(css.startsWith('body{padding-top:calc(10vw + 15vh)}')).toBe(true);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test('CSS has sourcemap URL', () => {
|
|
56
|
-
return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/nested-calc-test.css'), { encoding: 'utf8' }).then((css) => {
|
|
57
|
-
expect(css.includes('sourceMappingURL=')).toBe(true);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test('CSS sourcemap generated', () => {
|
|
62
|
-
expect.assertions(1);
|
|
63
|
-
return expect(fsPromises.access(path.resolve(publicPath, 'assets/stylesheets/nested-calc-test.css.map'))).resolves.toBe(undefined);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
8
|
test('Font file woff copied', () => {
|
|
67
9
|
expect.assertions(1);
|
|
68
10
|
return expect(fsPromises.access(path.resolve(publicPath, 'assets/fonts/font.woff'))).resolves.toBe(undefined);
|
|
@@ -73,81 +15,6 @@ test('Font file fake not copied', () => {
|
|
|
73
15
|
return expect(fsPromises.access(path.resolve(publicPath, 'assets/fonts/font.fake'))).rejects.toThrow('no such file or directory');
|
|
74
16
|
});
|
|
75
17
|
|
|
76
|
-
test('shared.js file exists', () => {
|
|
77
|
-
return Promise.all([
|
|
78
|
-
fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/shared.js'), { encoding: 'utf8' }).then((js) => {
|
|
79
|
-
expect(js.indexOf('console.log(`Shared file loaded`)')).not.toBe(-1);
|
|
80
|
-
}),
|
|
81
|
-
]);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test('main.js file exists', () => {
|
|
85
|
-
return Promise.all([
|
|
86
|
-
fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/main.js'), { encoding: 'utf8' }).then((js) => {
|
|
87
|
-
expect(js.indexOf('console.log(`Hello from main page!`')).not.toBe(-1);
|
|
88
|
-
}),
|
|
89
|
-
fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/alt/main.js'), { encoding: 'utf8' }).then((js) => {
|
|
90
|
-
expect(js.indexOf('console.log(`Hello from main page!`')).not.toBe(-1);
|
|
91
|
-
}),
|
|
92
|
-
]);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
test('other.js file exists', () => {
|
|
96
|
-
return fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/other.js'), { encoding: 'utf8' }).then((js) => {
|
|
97
|
-
expect(js.indexOf('console.log(`Hello from other page!`)')).not.toBe(-1);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
test('something.ts was converted', () => {
|
|
102
|
-
return Promise.all([
|
|
103
|
-
fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/something.js'), { encoding: 'utf8' }).then((js) => {
|
|
104
|
-
expect(js.indexOf('console.log({name:`something`})')).not.toBe(-1);
|
|
105
|
-
}),
|
|
106
|
-
]);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
test("alt/other.js file doesn't exist", async () => {
|
|
110
|
-
expect(fsPromises.stat(path.resolve(publicPath, 'assets/javascripts/alt/other.js'))).rejects.toThrow();
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
test('.env and .env.local files loaded', () => {
|
|
114
|
-
return Promise.all([
|
|
115
|
-
fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/main.js'), { encoding: 'utf8' }).then((js) => {
|
|
116
|
-
expect(js.indexOf('console.log(`env.host ==`,`https://test-local.tld`)')).not.toBe(-1);
|
|
117
|
-
expect(js.indexOf('console.log(`env.foo ==`,`foo-global`)')).not.toBe(-1);
|
|
118
|
-
expect(js.indexOf('console.log(`env.bar ==`,`bar-local`)')).not.toBe(-1);
|
|
119
|
-
expect(js.indexOf('console.log(`env.typeBoolTrue ==`,!0)')).not.toBe(-1);
|
|
120
|
-
expect(js.indexOf('console.log(`env.typeBoolFalse ==`,!1)')).not.toBe(-1);
|
|
121
|
-
expect(js.indexOf('console.log(`env.typeNumber ==`,123.456)')).not.toBe(-1);
|
|
122
|
-
}),
|
|
123
|
-
fsPromises.readFile(path.resolve(publicPath, 'env.html'), { encoding: 'utf8' }).then((html) => {
|
|
124
|
-
expect(html.indexOf('<p>HOST: https://test-local.tld</p>')).not.toBe(-1);
|
|
125
|
-
expect(html.indexOf('<p>TYPE_BOOL_TRUE: pass</p>')).not.toBe(-1);
|
|
126
|
-
expect(html.indexOf('<p>TYPE_BOOL_FALSE: pass</p>')).not.toBe(-1);
|
|
127
|
-
expect(html.indexOf('<p>TYPE_NUMBER: 123.456</p>')).not.toBe(-1);
|
|
128
|
-
}),
|
|
129
|
-
fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/env-test.css'), { encoding: 'utf8' }).then((css) => {
|
|
130
|
-
expect(css.indexOf('.env-test:before{content:"https://test-local.tld"}')).not.toBe(-1);
|
|
131
|
-
expect(css.indexOf('--env-test-bool-true:true')).not.toBe(-1);
|
|
132
|
-
expect(css.indexOf('--env-test-bool-false:false')).not.toBe(-1);
|
|
133
|
-
expect(css.indexOf('--env-test-type-number:123.456')).not.toBe(-1);
|
|
134
|
-
expect(css.indexOf('--env-test-type-empty:""')).not.toBe(-1);
|
|
135
|
-
}),
|
|
136
|
-
]);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
test('process.env available in html/data', () => {
|
|
140
|
-
return fsPromises.readFile(path.resolve(publicPath, 'env.html'), { encoding: 'utf8' }).then((html) => {
|
|
141
|
-
expect(html.indexOf('<p>HOST FROM GLOBAL JS: https://test-local.tld</p>')).not.toBe(-1);
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
test('currentPagePath available in templates', () => {
|
|
146
|
-
return fsPromises.readFile(path.resolve(publicPath, 'other.html'), { encoding: 'utf8' }).then((html) => {
|
|
147
|
-
expect(html.indexOf('Current page path: "/other"')).not.toBe(-1);
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
|
|
151
18
|
test('icons generated', () => {
|
|
152
19
|
return fsPromises.readFile(path.resolve(publicPath, 'assets/images/icons.svg'), { encoding: 'utf8' }).then((svg) => {
|
|
153
20
|
expect(svg.indexOf('<symbol id="example-arrow" viewBox="0 0 20 20">')).not.toBe(-1);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import fsPromises from 'fs/promises';
|
|
4
|
+
|
|
5
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
const publicPath = path.resolve(__dirname, 'public');
|
|
7
|
+
|
|
8
|
+
test('.env and .env.local files loaded', () => {
|
|
9
|
+
return Promise.all([
|
|
10
|
+
fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/main.js'), { encoding: 'utf8' }).then((js) => {
|
|
11
|
+
expect(js.indexOf('console.log(`env.host ==`,`https://test-local.tld`)')).not.toBe(-1);
|
|
12
|
+
expect(js.indexOf('console.log(`env.foo ==`,`foo-global`)')).not.toBe(-1);
|
|
13
|
+
expect(js.indexOf('console.log(`env.bar ==`,`bar-local`)')).not.toBe(-1);
|
|
14
|
+
expect(js.indexOf('console.log(`env.typeBoolTrue ==`,!0)')).not.toBe(-1);
|
|
15
|
+
expect(js.indexOf('console.log(`env.typeBoolFalse ==`,!1)')).not.toBe(-1);
|
|
16
|
+
expect(js.indexOf('console.log(`env.typeNumber ==`,123.456)')).not.toBe(-1);
|
|
17
|
+
expect(js.indexOf('console.log(`env.nonExisting ==`,``)')).not.toBe(-1);
|
|
18
|
+
}),
|
|
19
|
+
fsPromises.readFile(path.resolve(publicPath, 'env.html'), { encoding: 'utf8' }).then((html) => {
|
|
20
|
+
expect(html.indexOf('<p>HOST: https://test-local.tld</p>')).not.toBe(-1);
|
|
21
|
+
expect(html.indexOf('<p>TYPE_BOOL_TRUE: pass</p>')).not.toBe(-1);
|
|
22
|
+
expect(html.indexOf('<p>TYPE_BOOL_FALSE: pass</p>')).not.toBe(-1);
|
|
23
|
+
expect(html.indexOf('<p>TYPE_NUMBER: 123.456</p>')).not.toBe(-1);
|
|
24
|
+
expect(html.indexOf('<p>NON_EXISTING:</p>')).not.toBe(-1);
|
|
25
|
+
}),
|
|
26
|
+
fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/env-test.css'), { encoding: 'utf8' }).then((css) => {
|
|
27
|
+
expect(css.indexOf('.env-test:before{content:"https://test-local.tld"}')).not.toBe(-1);
|
|
28
|
+
expect(css.indexOf('--env-test-bool-true:true')).not.toBe(-1);
|
|
29
|
+
expect(css.indexOf('--env-test-bool-false:false')).not.toBe(-1);
|
|
30
|
+
expect(css.indexOf('--env-test-type-number:123.456')).not.toBe(-1);
|
|
31
|
+
expect(css.indexOf('--env-test-type-empty:""')).not.toBe(-1);
|
|
32
|
+
expect(css.indexOf('--env-test-non-existing:""')).not.toBe(-1);
|
|
33
|
+
}),
|
|
34
|
+
]);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('process.env available in html/data', () => {
|
|
38
|
+
return fsPromises.readFile(path.resolve(publicPath, 'env.html'), { encoding: 'utf8' }).then((html) => {
|
|
39
|
+
expect(html.indexOf('<p>HOST FROM GLOBAL JS: https://test-local.tld</p>')).not.toBe(-1);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import fsPromises from 'fs/promises';
|
|
4
|
+
|
|
5
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
const publicPath = path.resolve(__dirname, 'public');
|
|
7
|
+
|
|
8
|
+
test('shared.js file exists', () => {
|
|
9
|
+
return Promise.all([
|
|
10
|
+
fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/shared.js'), { encoding: 'utf8' }).then((js) => {
|
|
11
|
+
expect(js.indexOf('console.log(`Shared file loaded`)')).not.toBe(-1);
|
|
12
|
+
}),
|
|
13
|
+
]);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test('main.js file exists', () => {
|
|
17
|
+
return Promise.all([
|
|
18
|
+
fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/main.js'), { encoding: 'utf8' }).then((js) => {
|
|
19
|
+
expect(js.indexOf('console.log(`Hello from main page!`')).not.toBe(-1);
|
|
20
|
+
}),
|
|
21
|
+
fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/alt/main.js'), { encoding: 'utf8' }).then((js) => {
|
|
22
|
+
expect(js.indexOf('console.log(`Hello from main page!`')).not.toBe(-1);
|
|
23
|
+
}),
|
|
24
|
+
]);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('other.js file exists', () => {
|
|
28
|
+
return fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/other.js'), { encoding: 'utf8' }).then((js) => {
|
|
29
|
+
expect(js.indexOf('console.log(`Hello from other page!`)')).not.toBe(-1);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('something.ts was converted', () => {
|
|
34
|
+
return Promise.all([
|
|
35
|
+
fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/something.js'), { encoding: 'utf8' }).then((js) => {
|
|
36
|
+
expect(js.indexOf('console.log({name:`something`})')).not.toBe(-1);
|
|
37
|
+
}),
|
|
38
|
+
]);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("alt/other.js file doesn't exist", async () => {
|
|
42
|
+
expect(fsPromises.stat(path.resolve(publicPath, 'assets/javascripts/alt/other.js'))).rejects.toThrow();
|
|
43
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import fsPromises from 'fs/promises';
|
|
4
|
+
|
|
5
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
const publicPath = path.resolve(__dirname, 'public');
|
|
7
|
+
|
|
8
|
+
test('SASS variable test', () => {
|
|
9
|
+
return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/variable-test.css'), { encoding: 'utf8' }).then((css) => {
|
|
10
|
+
expect(css.startsWith('main{background:#fff;color:#222}')).toBe(true);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('SASS import test', () => {
|
|
15
|
+
return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/import-test.css'), { encoding: 'utf8' }).then((css) => {
|
|
16
|
+
expect(css.startsWith('.btn{background:#222;color:#fff}')).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('SASS sub-folder import test', () => {
|
|
21
|
+
return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/sub-folder/import-test.css'), { encoding: 'utf8' }).then((css) => {
|
|
22
|
+
expect(css.startsWith('.btn{background:#222;color:#fff}')).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('SASS autoprefixer test', () => {
|
|
27
|
+
return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/autoprefixer-test.css'), { encoding: 'utf8' }).then((css) => {
|
|
28
|
+
expect(css.startsWith('main{clip-path:polygon(0 0,100% 0,100% 100%,0 100%)}')).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('CSS nano ignore test', () => {
|
|
33
|
+
return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/ignore-test.css'), { encoding: 'utf8' }).then((css) => {
|
|
34
|
+
expect(css.startsWith(':root{--yes: ;--no:initial}')).toBe(true);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('CSS nano nested calc test', () => {
|
|
39
|
+
return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/nested-calc-test.css'), { encoding: 'utf8' }).then((css) => {
|
|
40
|
+
expect(css.startsWith('body{padding-top:calc(10vw + 15vh)}')).toBe(true);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('CSS has sourcemap URL', () => {
|
|
45
|
+
return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/nested-calc-test.css'), { encoding: 'utf8' }).then((css) => {
|
|
46
|
+
expect(css.includes('sourceMappingURL=')).toBe(true);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('CSS sourcemap generated', () => {
|
|
51
|
+
expect.assertions(1);
|
|
52
|
+
return expect(fsPromises.access(path.resolve(publicPath, 'assets/stylesheets/nested-calc-test.css.map'))).resolves.toBe(undefined);
|
|
53
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import fsPromises from 'fs/promises';
|
|
4
|
+
|
|
5
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
const publicPath = path.resolve(__dirname, 'public');
|
|
7
|
+
|
|
8
|
+
test('TWIG templates rendered and minified with JS and JSON data', () => {
|
|
9
|
+
return fsPromises.readFile(path.resolve(publicPath, 'index.html'), { encoding: 'utf8' }).then((html) => {
|
|
10
|
+
expect(html).toBe('<html><body><h1>Hello World!</h1></body></html>');
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('Multiple TWIG templates rendered', () => {
|
|
15
|
+
expect.assertions(1);
|
|
16
|
+
return expect(fsPromises.access(path.resolve(publicPath, 'other.html'))).resolves.toBe(undefined);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('currentPagePath available in templates', () => {
|
|
20
|
+
return fsPromises.readFile(path.resolve(publicPath, 'other.html'), { encoding: 'utf8' }).then((html) => {
|
|
21
|
+
expect(html.indexOf('Current page path: "/other"')).not.toBe(-1);
|
|
22
|
+
});
|
|
23
|
+
});
|