@nizza/devkit 0.1.0-alpha.11 → 0.1.0-alpha.13
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/cjs/executors/update-executors-file/index.cjs +2 -2
- package/dist/cjs/index.cjs +7 -7
- package/dist/cjs/node_modules/.pnpm/@vitejs_plugin-basic-ssl@1.0.2_vite@5.0.4/node_modules/@vitejs/plugin-basic-ssl/dist/chunks/certificate.cjs +19578 -0
- package/dist/cjs/node_modules/.pnpm/@vitejs_plugin-basic-ssl@1.0.2_vite@5.0.4/node_modules/@vitejs/plugin-basic-ssl/dist/index.cjs +40 -0
- package/dist/cjs/shared/utils.cjs +2 -2
- package/dist/cjs/{vite-utils → vitejs}/config-builder/configs/base.cjs +3 -3
- package/dist/cjs/{vite-utils → vitejs}/config-builder/configs/lib.cjs +2 -1
- package/dist/cjs/{vite-utils → vitejs}/config-builder/plugins.cjs +17 -3
- package/dist/cjs/{vite-utils → vitejs}/config-builder/shared/types.cjs +1 -0
- package/dist/cjs/{vite-utils → vitejs}/plugins/third-party-css-inject/utils.cjs +1 -3
- package/dist/esm/executors/update-executors-file/index.mjs +2 -2
- package/dist/esm/index.mjs +7 -7
- package/dist/esm/node_modules/.pnpm/@vitejs_plugin-basic-ssl@1.0.2_vite@5.0.4/node_modules/@vitejs/plugin-basic-ssl/dist/chunks/certificate.mjs +19576 -0
- package/dist/esm/node_modules/.pnpm/@vitejs_plugin-basic-ssl@1.0.2_vite@5.0.4/node_modules/@vitejs/plugin-basic-ssl/dist/index.mjs +35 -0
- package/dist/esm/{vite-utils → vitejs}/config-builder/configs/base.mjs +4 -4
- package/dist/esm/{vite-utils → vitejs}/config-builder/configs/lib.mjs +2 -1
- package/dist/esm/{vite-utils → vitejs}/config-builder/plugins.mjs +17 -4
- package/dist/esm/{vite-utils → vitejs}/config-builder/shared/types.mjs +1 -0
- package/dist/esm/{vite-utils → vitejs}/plugins/third-party-css-inject/utils.mjs +1 -3
- package/package.json +2 -4
- /package/dist/cjs/{vite-utils → vitejs}/config-builder/configs/app.cjs +0 -0
- /package/dist/cjs/{vite-utils → vitejs}/config-builder/configs/index.cjs +0 -0
- /package/dist/cjs/{vite-utils → vitejs}/config-builder/configs/script.cjs +0 -0
- /package/dist/cjs/{vite-utils → vitejs}/config-builder/main.cjs +0 -0
- /package/dist/cjs/{vite-utils → vitejs}/config-builder/shared/utils/helpers.cjs +0 -0
- /package/dist/cjs/{vite-utils → vitejs}/config-builder/shared/utils/projectConfig.cjs +0 -0
- /package/dist/cjs/{vite-utils → vitejs}/config-builder/shared/utils/viteCommand.cjs +0 -0
- /package/dist/cjs/{vite-utils → vitejs}/plugins/shadow-dom-inject-css/index.cjs +0 -0
- /package/dist/cjs/{vite-utils → vitejs}/plugins/third-party-css-inject/main.cjs +0 -0
- /package/dist/esm/{vite-utils → vitejs}/config-builder/configs/app.mjs +0 -0
- /package/dist/esm/{vite-utils → vitejs}/config-builder/configs/index.mjs +0 -0
- /package/dist/esm/{vite-utils → vitejs}/config-builder/configs/script.mjs +0 -0
- /package/dist/esm/{vite-utils → vitejs}/config-builder/main.mjs +0 -0
- /package/dist/esm/{vite-utils → vitejs}/config-builder/shared/utils/helpers.mjs +0 -0
- /package/dist/esm/{vite-utils → vitejs}/config-builder/shared/utils/projectConfig.mjs +0 -0
- /package/dist/esm/{vite-utils → vitejs}/config-builder/shared/utils/viteCommand.mjs +0 -0
- /package/dist/esm/{vite-utils → vitejs}/plugins/shadow-dom-inject-css/index.mjs +0 -0
- /package/dist/esm/{vite-utils → vitejs}/plugins/third-party-css-inject/main.mjs +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { promises } from 'node:fs';
|
|
3
|
+
|
|
4
|
+
const defaultCacheDir = "node_modules/.vite";
|
|
5
|
+
function viteBasicSslPlugin() {
|
|
6
|
+
return {
|
|
7
|
+
name: "vite:basic-ssl",
|
|
8
|
+
async configResolved(config) {
|
|
9
|
+
const certificate = await getCertificate((config.cacheDir ?? defaultCacheDir) + "/basic-ssl");
|
|
10
|
+
const https = () => ({ cert: certificate, key: certificate });
|
|
11
|
+
config.server.https = Object.assign({}, config.server.https, https());
|
|
12
|
+
config.preview.https = Object.assign({}, config.preview.https, https());
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
async function getCertificate(cacheDir) {
|
|
17
|
+
const cachePath = path.join(cacheDir, "_cert.pem");
|
|
18
|
+
try {
|
|
19
|
+
const [stat, content] = await Promise.all([
|
|
20
|
+
promises.stat(cachePath),
|
|
21
|
+
promises.readFile(cachePath, "utf8")
|
|
22
|
+
]);
|
|
23
|
+
if (Date.now() - stat.ctime.valueOf() > 30 * 24 * 60 * 60 * 1e3) {
|
|
24
|
+
throw new Error("cache is outdated.");
|
|
25
|
+
}
|
|
26
|
+
return content;
|
|
27
|
+
} catch {
|
|
28
|
+
const content = (await import('./chunks/certificate.mjs')).createCertificate();
|
|
29
|
+
promises.mkdir(cacheDir, { recursive: true }).then(() => promises.writeFile(cachePath, content)).catch(() => {
|
|
30
|
+
});
|
|
31
|
+
return content;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { viteBasicSslPlugin as default, getCertificate };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { existsSync } from 'fs';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
import { bundleAnalysisPlugin, httpsServerPlugin, basePlugins } from '../plugins.mjs';
|
|
2
4
|
import { Target, ViteMode, Flag, Stage } from '../shared/types.mjs';
|
|
3
5
|
import { getPlugins, when } from '../shared/utils/helpers.mjs';
|
|
4
6
|
import 'minimatch';
|
|
5
7
|
import '../../../shared/logger.mjs';
|
|
6
8
|
import '@nx/devkit';
|
|
7
9
|
import 'crypto';
|
|
8
|
-
import { existsSync } from 'fs';
|
|
9
|
-
import { resolve } from 'path';
|
|
10
10
|
import 'chalk';
|
|
11
11
|
import 'mri';
|
|
12
12
|
import 'vite';
|
|
@@ -30,7 +30,7 @@ const getBaseConfig = (ctx)=>{
|
|
|
30
30
|
const envFilePath = existsSync(resolve(path, 'src', envPath)) ? envPath : fallbackEnvPath;
|
|
31
31
|
return {
|
|
32
32
|
envPrefix,
|
|
33
|
-
plugins: getPlugins(ctx, basePlugins, bundleAnalysisPlugin),
|
|
33
|
+
plugins: getPlugins(ctx, basePlugins, httpsServerPlugin, bundleAnalysisPlugin),
|
|
34
34
|
resolve: {
|
|
35
35
|
alias: {
|
|
36
36
|
...when(resolveEnvs.default && !omittedStages.includes(stage), {
|
|
@@ -17,6 +17,7 @@ import 'crypto';
|
|
|
17
17
|
import 'fs';
|
|
18
18
|
import 'chalk';
|
|
19
19
|
import 'mri';
|
|
20
|
+
import viteBasicSslPlugin from '../../node_modules/.pnpm/@vitejs_plugin-basic-ssl@1.0.2_vite@5.0.4/node_modules/@vitejs/plugin-basic-ssl/dist/index.mjs';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Base plugins configuration for apps and libs.
|
|
@@ -63,13 +64,13 @@ import 'mri';
|
|
|
63
64
|
filename: 'bundle-analysis.html'
|
|
64
65
|
})
|
|
65
66
|
],
|
|
66
|
-
condition: ({ viteCmd })=>viteCmd.flags?.[Flag.ANALYZE]
|
|
67
|
+
condition: ({ viteCmd })=>viteCmd.flags?.[Flag.ANALYZE]
|
|
67
68
|
};
|
|
68
69
|
/**
|
|
69
70
|
* Plugin configuration for injecting CSS into JS files
|
|
70
71
|
* using vite-plugin-css-injected-by-js.
|
|
71
72
|
*/ const injectCssByJsPlugin = {
|
|
72
|
-
generate: (
|
|
73
|
+
generate: ()=>[
|
|
73
74
|
cssInjectedByJsPlugin()
|
|
74
75
|
],
|
|
75
76
|
condition: ({ projectConfig })=>!projectConfig.shadowDom
|
|
@@ -78,10 +79,22 @@ import 'mri';
|
|
|
78
79
|
* Plugin configuration for injecting CSS into Shadow Dom.
|
|
79
80
|
* using local plugin.
|
|
80
81
|
*/ const injectCssIntoShadowDomPlugin = {
|
|
81
|
-
generate: (
|
|
82
|
+
generate: ()=>[
|
|
82
83
|
injectCssIntoShadowDom()
|
|
83
84
|
],
|
|
84
85
|
condition: ({ projectConfig })=>projectConfig.shadowDom
|
|
85
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* Use the plugin @vitejs/plugin-basic-ssl to create a SSL
|
|
89
|
+
* certificate and create https server.
|
|
90
|
+
*/ const httpsServerPlugin = {
|
|
91
|
+
generate: ()=>[
|
|
92
|
+
viteBasicSslPlugin()
|
|
93
|
+
],
|
|
94
|
+
condition: ({ viteCmd })=>{
|
|
95
|
+
console.log('🚀 ~ file: plugins.ts:92 ~ viteCmd.flags:', viteCmd.flags);
|
|
96
|
+
return viteCmd.flags?.[Flag.HTTPS];
|
|
97
|
+
}
|
|
98
|
+
};
|
|
86
99
|
|
|
87
|
-
export { basePlugins, bundleAnalysisPlugin, dtsPlugin, injectCssByJsPlugin, injectCssIntoShadowDomPlugin };
|
|
100
|
+
export { basePlugins, bundleAnalysisPlugin, dtsPlugin, httpsServerPlugin, injectCssByJsPlugin, injectCssIntoShadowDomPlugin };
|
|
@@ -64,13 +64,11 @@ async function buildCSSInjectionCode(execute) {
|
|
|
64
64
|
*/ function injectionCSSCodePlugin(execute) {
|
|
65
65
|
return {
|
|
66
66
|
name: 'vite:third-party-css-inject',
|
|
67
|
-
// @ts-ignore
|
|
68
67
|
resolveId (id) {
|
|
69
68
|
if (id == cssInjectedByJsId) {
|
|
70
69
|
return id;
|
|
71
70
|
}
|
|
72
71
|
},
|
|
73
|
-
// @ts-ignore
|
|
74
72
|
load (id) {
|
|
75
73
|
if (id == cssInjectedByJsId) {
|
|
76
74
|
let executeJs = [];
|
|
@@ -84,7 +82,7 @@ async function buildCSSInjectionCode(execute) {
|
|
|
84
82
|
return `try{if(typeof document != 'undefined'){
|
|
85
83
|
const waitForElement=${waitForElement.toString()};
|
|
86
84
|
${executeJs.join(' ')}
|
|
87
|
-
}}catch(e){console.error('vite
|
|
85
|
+
}}catch(e){console.error('vite:third-party-css-inject', e);}`;
|
|
88
86
|
}
|
|
89
87
|
}
|
|
90
88
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nizza/devkit",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/cjs/index.cjs",
|
|
6
6
|
"module": "dist/esm/index.mjs",
|
|
@@ -39,10 +39,8 @@
|
|
|
39
39
|
"rollup": "^4.2.0",
|
|
40
40
|
"rollup-plugin-copy": "^3.5.0",
|
|
41
41
|
"rollup-plugin-delete": "^2.0.0",
|
|
42
|
-
"rollup-plugin-dts": "^6.1.0",
|
|
43
42
|
"rollup-plugin-dts-bundle-generator": "^1.4.0",
|
|
44
|
-
"rollup-plugin-swc3": "^0.10.3"
|
|
45
|
-
"rollup-plugin-ts": "^3.4.5"
|
|
43
|
+
"rollup-plugin-swc3": "^0.10.3"
|
|
46
44
|
},
|
|
47
45
|
"peerDependencies": {
|
|
48
46
|
"@nx/devkit": "17.0.2",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|