gdu 4.1.2 → 4.1.5
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/dist/commands/build/buildSSR.js +5 -0
- package/dist/commands/start/runSPA.js +2 -1
- package/dist/config/babel.config.d.ts +1 -0
- package/dist/config/babel.config.js +3 -0
- package/dist/config/next.config.d.ts +10 -3
- package/dist/config/next.config.js +16 -5
- package/dist/config/pathNormaliser.d.ts +12 -0
- package/dist/config/pathNormaliser.js +32 -0
- package/dist/config/webpack/webpack.config.js +17 -17
- package/dist/lib/config.d.ts +1 -0
- package/dist/lib/config.js +3 -1
- package/package.json +1 -1
|
@@ -17,6 +17,11 @@ const buildSSR = async (guruConfig) => {
|
|
|
17
17
|
stdio: 'inherit',
|
|
18
18
|
cwd: roots_1.PROJECT_ROOT,
|
|
19
19
|
localDir: roots_1.GDU_ROOT,
|
|
20
|
+
extendEnv: true,
|
|
21
|
+
env: {
|
|
22
|
+
NODE_ENV: 'production',
|
|
23
|
+
APP_ENV: process.env.APP_ENV || 'prod',
|
|
24
|
+
},
|
|
20
25
|
})
|
|
21
26
|
.then((result) => {
|
|
22
27
|
console.log(`${kleur_1.dim('SUCCESS!')}`, `${kleur_1.dim('Listening')}: ${kleur_1.blue(result === null || result === void 0 ? void 0 : result.all)}`);
|
|
@@ -31,9 +31,10 @@ const hosts = ['localhost', localhost];
|
|
|
31
31
|
const runSPA = async (guruConfig) => {
|
|
32
32
|
const hooks = hooks_1.getHooks();
|
|
33
33
|
console.log(`${kleur_1.cyan('Starting dev server...')}`);
|
|
34
|
+
const appEnv = process.env.APP_ENV || 'dev';
|
|
34
35
|
const webpackConfig = hooks.webpackConfig
|
|
35
36
|
.call(webpack_config_1.default())
|
|
36
|
-
.find(({ name }) => name ===
|
|
37
|
+
.find(({ name }) => name === appEnv);
|
|
37
38
|
const consumerHtmlTemplate = getConsumerHtmlTemplate(guruConfig);
|
|
38
39
|
webpackConfig.plugins.push(new html_webpack_plugin_1.default({
|
|
39
40
|
template: consumerHtmlTemplate !== null && consumerHtmlTemplate !== void 0 ? consumerHtmlTemplate : 'auto',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const { join } = require('path');
|
|
3
3
|
const browsers = require('browserslist-config-autoguru');
|
|
4
|
+
const { PROJECT_ROOT } = require('../lib/roots');
|
|
4
5
|
module.exports = (guruConfig) => {
|
|
5
6
|
let hasRelay = false;
|
|
6
7
|
try {
|
|
@@ -40,9 +41,11 @@ module.exports = (guruConfig) => {
|
|
|
40
41
|
haste: false,
|
|
41
42
|
isDevVariable: '__DEV__',
|
|
42
43
|
eagerESModules: true,
|
|
44
|
+
artifactDirectory: join(PROJECT_ROOT, '../../', 'packages', 'relay', '__generated__'),
|
|
43
45
|
},
|
|
44
46
|
],
|
|
45
47
|
require.resolve('babel-plugin-treat'),
|
|
48
|
+
[require.resolve('./pathNormaliser')],
|
|
46
49
|
].filter(Boolean),
|
|
47
50
|
};
|
|
48
51
|
};
|
|
@@ -6,9 +6,16 @@ export declare const defaultSecurityHeaders: {
|
|
|
6
6
|
export declare const createNextJSConfig: (buildEnv: any) => {
|
|
7
7
|
distDir: string;
|
|
8
8
|
reactStrictMode: boolean;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
swcMinify: boolean;
|
|
10
|
+
assetPrefix: string;
|
|
11
|
+
i18n: {
|
|
12
|
+
locales: string[];
|
|
13
|
+
defaultLocale: string;
|
|
14
|
+
};
|
|
15
|
+
typescript: {
|
|
16
|
+
transpileOnly: boolean;
|
|
17
|
+
ignoreDevErrors: boolean;
|
|
18
|
+
ignoreBuildErrors: boolean;
|
|
12
19
|
};
|
|
13
20
|
images: {
|
|
14
21
|
formats: string[];
|
|
@@ -28,6 +28,7 @@ const next_plugin_1 = require("@vanilla-extract/next-plugin");
|
|
|
28
28
|
const dotenv_webpack_1 = __importDefault(require("dotenv-webpack"));
|
|
29
29
|
const next_transpile_modules_1 = __importDefault(require("next-transpile-modules"));
|
|
30
30
|
const webpack_1 = require("webpack");
|
|
31
|
+
const config_1 = require("../lib/config");
|
|
31
32
|
const misc_1 = require("../lib/misc");
|
|
32
33
|
const roots_1 = require("../lib/roots");
|
|
33
34
|
const configs_1 = require("../utils/configs");
|
|
@@ -55,6 +56,7 @@ const allowedScriptSources = [
|
|
|
55
56
|
'*.gstatic.com',
|
|
56
57
|
'*.googleadservices.com',
|
|
57
58
|
'*.heapanalytics.com',
|
|
59
|
+
'heapanalytics.com',
|
|
58
60
|
'*.doubleclick.net',
|
|
59
61
|
'*.mapbox.com',
|
|
60
62
|
'*.quantserve.com',
|
|
@@ -97,18 +99,27 @@ exports.defaultSecurityHeaders = [
|
|
|
97
99
|
},
|
|
98
100
|
{
|
|
99
101
|
key: 'Content-Security-Policy',
|
|
100
|
-
value: `frame-ancestors https://*.autoguru.com.au; frame-src ${allowedIFrameSources}; style-src ${allowedStyleSources}; img-src ${allowedImageSources} data: ${allowedDataDomains}; font-src ${allowedFontSources}; worker-src ${allowedDataSources}; child-src ${allowedDataSources}; object-src ${allowedObjectSources}
|
|
102
|
+
value: `frame-ancestors https://*.autoguru.com.au; frame-src ${allowedIFrameSources}; style-src ${allowedStyleSources}; img-src ${allowedImageSources} data: ${allowedDataDomains}; font-src ${allowedFontSources}; worker-src ${allowedDataSources}; child-src ${allowedDataSources}; object-src ${allowedObjectSources};connect-src ${allowedScriptSources}; script-src-elem ${allowedScriptSources}; script-src ${allowedScriptSources};`,
|
|
101
103
|
},
|
|
102
104
|
];
|
|
103
105
|
const createNextJSConfig = (buildEnv) => {
|
|
106
|
+
var _a, _b;
|
|
104
107
|
const isDev = !misc_1.isEnvProduction();
|
|
105
108
|
const env = process.env.APP_ENV || (isDev ? 'dev' : buildEnv);
|
|
109
|
+
const assetPrefix = isDev ? '' : (_b = (_a = config_1.getGuruConfig()) === null || _a === void 0 ? void 0 : _a.publicPath) !== null && _b !== void 0 ? _b : '';
|
|
106
110
|
return {
|
|
107
111
|
distDir: `dist/${env}`,
|
|
108
112
|
reactStrictMode: true,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
113
|
+
swcMinify: true,
|
|
114
|
+
assetPrefix,
|
|
115
|
+
i18n: {
|
|
116
|
+
locales: ['en'],
|
|
117
|
+
defaultLocale: 'en',
|
|
118
|
+
},
|
|
119
|
+
typescript: {
|
|
120
|
+
transpileOnly: true,
|
|
121
|
+
ignoreDevErrors: true,
|
|
122
|
+
ignoreBuildErrors: true,
|
|
112
123
|
},
|
|
113
124
|
images: {
|
|
114
125
|
formats: ['image/avif', 'image/webp'],
|
|
@@ -150,5 +161,5 @@ const createNextJSConfig = (buildEnv) => {
|
|
|
150
161
|
};
|
|
151
162
|
};
|
|
152
163
|
exports.createNextJSConfig = createNextJSConfig;
|
|
153
|
-
const createNextJSTranspiledConfig = () => withVanillaExtract(exports.withTM(exports.createNextJSConfig('
|
|
164
|
+
const createNextJSTranspiledConfig = () => withVanillaExtract(exports.withTM(exports.createNextJSConfig('prod')));
|
|
154
165
|
exports.createNextJSTranspiledConfig = createNextJSTranspiledConfig;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const replacer = (filepath) => filepath.replace(/\\/g, '/');
|
|
3
|
+
const PathNormaliserPlugin = function (api) {
|
|
4
|
+
if (process.platform === 'win32') {
|
|
5
|
+
const t = api.types;
|
|
6
|
+
return {
|
|
7
|
+
name: 'path-normaliser',
|
|
8
|
+
visitor: {
|
|
9
|
+
CallExpression: {
|
|
10
|
+
enter: function (nodePath) {
|
|
11
|
+
const callee = nodePath.get('callee');
|
|
12
|
+
if (callee.isIdentifier() &&
|
|
13
|
+
callee.equals('name', 'require')) {
|
|
14
|
+
const arg = nodePath.get('arguments.0');
|
|
15
|
+
if (arg && arg.isStringLiteral()) {
|
|
16
|
+
const sourcePath = arg.node.value;
|
|
17
|
+
const targetPath = replacer(sourcePath);
|
|
18
|
+
if (sourcePath !== targetPath) {
|
|
19
|
+
arg.replaceWith(t.stringLiteral(targetPath));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
name: 'path-normaliser',
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
module.exports = PathNormaliserPlugin;
|
|
@@ -76,7 +76,6 @@ const baseOptions = (buildEnv, isMultiEnv) => ({
|
|
|
76
76
|
mode: isDev ? 'development' : 'production',
|
|
77
77
|
entry: {
|
|
78
78
|
main: [
|
|
79
|
-
!isDev && path_1.join(gduEntryPath, '/spa/set-public-path.js'),
|
|
80
79
|
path_1.join(gduEntryPath, '/polyfill.js'),
|
|
81
80
|
path_1.join(gduEntryPath, '/spa/client.js'),
|
|
82
81
|
].filter(Boolean),
|
|
@@ -298,22 +297,23 @@ const baseOptions = (buildEnv, isMultiEnv) => ({
|
|
|
298
297
|
].filter(Boolean),
|
|
299
298
|
});
|
|
300
299
|
const { outputPath } = config_1.getGuruConfig();
|
|
301
|
-
const makeWebpackConfig = (buildEnv, isMultiEnv) => {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}
|
|
300
|
+
const makeWebpackConfig = (buildEnv, isMultiEnv) => ({
|
|
301
|
+
name: buildEnv,
|
|
302
|
+
output: {
|
|
303
|
+
path: `${outputPath}/${!isMultiEnv && buildEnv === 'prod' ? '' : buildEnv}`,
|
|
304
|
+
publicPath: isDev
|
|
305
|
+
? '/'
|
|
306
|
+
: buildEnv === 'prod'
|
|
307
|
+
? `#{PUBLIC_PATH_BASE}/${config_1.getProjectFolderName()}/`
|
|
308
|
+
: `https://static-mfe-${buildEnv}.autoguru.io/${config_1.getProjectFolderName()}/`,
|
|
309
|
+
filename: `${fileMask}.js`,
|
|
310
|
+
chunkFilename: `chunks/${fileMask}.js`,
|
|
311
|
+
hashFunction: 'sha256',
|
|
312
|
+
crossOriginLoading: 'anonymous',
|
|
313
|
+
sourceMapFilename: 'sourceMaps/[file].map',
|
|
314
|
+
pathinfo: false,
|
|
315
|
+
},
|
|
316
|
+
});
|
|
317
317
|
const buildConfigs = () => {
|
|
318
318
|
const buildEnvs = configs_1.getBuildEnvs();
|
|
319
319
|
return buildEnvs.map((buildEnv) => ({
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -12,3 +12,4 @@ export interface GuruConfig {
|
|
|
12
12
|
export declare const getGuruConfig: (location?: string) => GuruConfig | null;
|
|
13
13
|
export declare const decorateConfig: (guruConfig: Partial<GuruConfig>) => GuruConfig;
|
|
14
14
|
export declare const getProjectName: (location?: string) => any;
|
|
15
|
+
export declare const getProjectFolderName: (location?: string) => string;
|
package/dist/lib/config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProjectName = exports.decorateConfig = exports.getGuruConfig = void 0;
|
|
3
|
+
exports.getProjectFolderName = exports.getProjectName = exports.decorateConfig = exports.getGuruConfig = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const diary_1 = require("diary");
|
|
6
6
|
const resolve_1 = require("./resolve");
|
|
@@ -52,3 +52,5 @@ const decorateConfig = (guruConfig) => {
|
|
|
52
52
|
exports.decorateConfig = decorateConfig;
|
|
53
53
|
const getProjectName = (location = roots_1.PROJECT_ROOT) => require(path_1.join(exports.getGuruConfig(location).__configPath, './package.json')).name;
|
|
54
54
|
exports.getProjectName = getProjectName;
|
|
55
|
+
const getProjectFolderName = (location = roots_1.PROJECT_ROOT) => path_1.basename(path_1.join(exports.getGuruConfig(location).__configPath));
|
|
56
|
+
exports.getProjectFolderName = getProjectFolderName;
|