@docsvision/management-console-extension-build 1.0.0 → 6.2.0-beta.2

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/package.json CHANGED
@@ -1,23 +1,18 @@
1
1
  {
2
2
  "name": "@docsvision/management-console-extension-build",
3
- "version": "1.0.0",
3
+ "version": "6.2.0-beta.2",
4
4
  "description": "Helper tools for building Management Console extensions.",
5
5
  "scripts": {},
6
6
  "dependencies": {
7
7
  "autoprefixer": "9.8.5",
8
8
  "postcss-custom-properties": "9.1.1",
9
- "rollup": "2.56.3",
10
- "rollup-plugin-includepaths": "0.2.3",
11
- "rollup-plugin-postcss": "3.1.2",
12
- "rollup-plugin-terser": "6.1.0",
13
9
  "tslib": "2.3.1",
14
10
  "typescript": "4.7.4",
15
11
  "@types/react": "17.0.3",
16
12
  "@types/react-dom": "17.0.3",
17
- "@rollup/plugin-commonjs": "12.0.0",
18
- "@rollup/plugin-node-resolve": "8.0.0",
19
- "@rollup/plugin-replace": "2.3.3",
20
- "@rollup/plugin-typescript": "8.2.5",
13
+ "vite": "^7.0.6",
14
+ "vite-tsconfig-paths": "^5.1.4",
15
+ "@vitejs/plugin-react": "^4.7.0",
21
16
  "del": "5.1.0",
22
17
  "gulp": "4.0.2"
23
18
  },
@@ -0,0 +1,162 @@
1
+ import { existsSync, readFileSync, writeFileSync } from "fs";
2
+ import { defineConfig } from "vite";
3
+ import react from "@vitejs/plugin-react";
4
+ import tsconfigPaths from "vite-tsconfig-paths";
5
+ import autoprefixer from "autoprefixer";
6
+ import postcssCustomProperties from "postcss-custom-properties";
7
+ import path from "path";
8
+
9
+ const EXTERNAL_EXACT = new Set([
10
+ "react",
11
+ "react-dom",
12
+ "@emotion/react",
13
+ "@emotion/styled",
14
+ "@mui/styled-engine",
15
+ "@mui/material",
16
+ "@mui/material/styles",
17
+ "@mui/system",
18
+ "@mui/private-theming",
19
+ "@mui/x-tree-view",
20
+ ]);
21
+
22
+ const isExternal = (id) => {
23
+ if (EXTERNAL_EXACT.has(id)) return true;
24
+ if (id.startsWith("@emotion/react/")) return true;
25
+ if (id.startsWith("@mui/styled-engine/")) return true;
26
+ if (id.startsWith("@mui/material/")) return true;
27
+ if (id.startsWith("@mui/system/")) return true;
28
+ if (id.startsWith("@mui/private-theming/")) return true;
29
+ if (id.startsWith("@mui/x-tree-view/")) return true;
30
+ return false;
31
+ };
32
+
33
+ const globals = (id) => {
34
+ if (id === "react") return "React";
35
+ if (id === "react-dom") return "ReactDOM";
36
+ if (id === "@emotion/react") return "EmotionReact";
37
+ if (id === "@emotion/styled") return "EmotionStyled";
38
+ if (id === "@mui/styled-engine") return "MuiStyledEngine";
39
+ if (id === "@mui/material") return "MuiMaterial";
40
+ if (id === "@mui/material/styles") return "MuiMaterial";
41
+ if (id === "@mui/system") return "MuiSystem";
42
+ if (id === "@mui/private-theming") return "MuiPrivateTheming";
43
+ if (id === "@mui/x-tree-view") return "MuiXTreeView";
44
+ if (id === "@docsvision/management-console") return "Library";
45
+
46
+ if (id.startsWith("@emotion/react/")) return "EmotionReact";
47
+ if (id.startsWith("@mui/styled-engine/")) return "MuiStyledEngine";
48
+ if (id.startsWith("@mui/material/")) return "MuiMaterial";
49
+ if (id.startsWith("@mui/system/")) return "MuiSystem";
50
+ if (id.startsWith("@mui/private-theming/")) return "MuiPrivateTheming";
51
+ if (id.startsWith("@mui/x-tree-view/")) return "MuiXTreeView";
52
+
53
+ return undefined;
54
+ };
55
+
56
+ export function getBaseConfig(
57
+ name,
58
+ inputFileName,
59
+ outputFileName,
60
+ outputCssFileName,
61
+ foldername,
62
+ ) {
63
+ if (!name) throw new Error("name is empty");
64
+ if (!inputFileName) throw new Error("inputFileName is empty");
65
+ if (!outputFileName) throw new Error("outputFileName is empty");
66
+ if (!outputCssFileName) throw new Error("outputCssFileName is empty");
67
+
68
+ return defineConfig(({ mode }) => {
69
+ const isProd = mode === "production";
70
+ const managementConsoleCssPath = path.resolve(
71
+ process.cwd(),
72
+ "node_modules",
73
+ "@docsvision",
74
+ "management-console",
75
+ "index.css",
76
+ );
77
+ const cssOutputPath = path.resolve(
78
+ process.cwd(),
79
+ "dist",
80
+ foldername ?? name,
81
+ outputCssFileName,
82
+ );
83
+
84
+ const injectManagementConsoleCssPlugin = {
85
+ name: "inject-management-console-css",
86
+ apply: "build",
87
+ writeBundle() {
88
+ if (!existsSync(managementConsoleCssPath)) {
89
+ this.warn(
90
+ `Management console CSS not found at ${managementConsoleCssPath}, skipping injection.`,
91
+ );
92
+ return;
93
+ }
94
+
95
+ if (!existsSync(cssOutputPath)) {
96
+ this.warn(
97
+ `Management console CSS output file ${cssOutputPath} not found, skipping injection.`,
98
+ );
99
+ return;
100
+ }
101
+
102
+ const sourceToInject = readFileSync(managementConsoleCssPath, "utf-8");
103
+ const currentCss = readFileSync(cssOutputPath, "utf-8");
104
+ writeFileSync(cssOutputPath, `${sourceToInject}\n${currentCss}`);
105
+ },
106
+ };
107
+
108
+ return {
109
+ define: { "process.env.NODE_ENV": JSON.stringify("production") },
110
+ plugins: [react(), tsconfigPaths(), injectManagementConsoleCssPlugin],
111
+ css: {
112
+ postcss: { plugins: [autoprefixer(), postcssCustomProperties()] },
113
+ devSourcemap: true,
114
+ },
115
+ optimizeDeps: { exclude: Array.from(EXTERNAL_EXACT) },
116
+ build: {
117
+ target: "esnext",
118
+ minify: isProd ? "terser" : false,
119
+ sourcemap: true,
120
+ emptyOutDir: true,
121
+ copyPublicDir: false,
122
+ cssCodeSplit: false,
123
+ outDir: path.posix.join("dist", foldername ?? name),
124
+ lib: {
125
+ entry: path.resolve(process.cwd(), inputFileName),
126
+ name,
127
+ fileName: () => outputFileName,
128
+ formats: ["umd"],
129
+ },
130
+ rollupOptions: {
131
+ external: isExternal,
132
+ output: {
133
+ format: "umd",
134
+ name,
135
+ entryFileNames: outputFileName,
136
+ assetFileNames: () => outputCssFileName,
137
+ globals,
138
+ },
139
+ onwarn(warning, warn) {
140
+ if (
141
+ warning.code === "MISSING_GLOBAL_NAME" ||
142
+ String(warning.message || "").includes(
143
+ "No name was provided for external module",
144
+ )
145
+ ) {
146
+ throw new Error(
147
+ `Missing output.globals mapping: ${warning.message}`,
148
+ );
149
+ }
150
+ if (
151
+ warning.code === "UNUSED_EXTERNAL_IMPORT" ||
152
+ String(warning.message).includes("__PURE__")
153
+ ) {
154
+ return;
155
+ }
156
+ warn(warning);
157
+ },
158
+ },
159
+ },
160
+ };
161
+ });
162
+ }
@@ -1,79 +0,0 @@
1
- const typescript = require("@rollup/plugin-typescript");
2
- const commonjs = require("@rollup/plugin-commonjs");
3
- const { nodeResolve } = require('@rollup/plugin-node-resolve');
4
- const replace = require("@rollup/plugin-replace");
5
- const { terser } = require("rollup-plugin-terser");
6
- const includePaths = require("rollup-plugin-includepaths");
7
- const postcss = require("rollup-plugin-postcss");
8
- const path = require("path");
9
- const autoprefixer = require("autoprefixer");
10
- const postcssCustomProperties = require("postcss-custom-properties");
11
-
12
-
13
- const NODE_ENV_PRODUCTION = "production";
14
- module.exports = {};
15
-
16
-
17
- module.exports.getBaseConfig = function(name, inputFileName, outputFileName, outputCssFileName, globals, paths, external) {
18
- if (!name) {
19
- throw "name is empty";
20
- }
21
-
22
- if (!inputFileName) {
23
- throw "inputFileName is empty"
24
- }
25
-
26
- if (!outputFileName) {
27
- throw "outputFileName is empty";
28
- }
29
-
30
- if (!outputCssFileName) {
31
- throw "outputCssFileName is empty";
32
- }
33
-
34
- const isProd = process.env.NODE_ENV == NODE_ENV_PRODUCTION;
35
-
36
-
37
- const plugins = [];
38
- plugins.push(nodeResolve());
39
- plugins.push(replace(
40
- { "process.env.NODE_ENV": `"${process.env.NODE_ENV}"`,
41
- "/assets/": "/bundle/assets/"
42
- }));
43
- plugins.push(includePaths({ paths: ["./src"] }));
44
- plugins.push(commonjs({
45
- include: /node_modules/,
46
- }));
47
- plugins.push(postcss({
48
- extract: path.resolve(outputCssFileName),
49
- plugins: [ autoprefixer(), postcssCustomProperties() ],
50
- minimize: isProd,
51
- sourceMap: true,
52
- use: [
53
- ["sass", {
54
- includePaths: [
55
- "./node_modules"
56
- ]
57
- }]
58
- ]
59
- }));
60
- plugins.push(typescript({ }));
61
-
62
- if (isProd) {
63
- plugins.push(terser());
64
- }
65
-
66
- return {
67
- external: external || [],
68
- input: inputFileName,
69
- output: {
70
- file: outputFileName,
71
- format: "umd",
72
- globals: globals || {},
73
- paths: paths || {},
74
- name: name,
75
- sourcemap: true
76
- },
77
- plugins: plugins
78
- };
79
- }
package/variables.js DELETED
@@ -1,11 +0,0 @@
1
- module.exports = {};
2
-
3
- module.exports.globals = {
4
- 'react': 'React',
5
- 'react-dom': 'ReactDOM'
6
- };
7
-
8
- module.exports.external = [
9
- 'react',
10
- 'react-dom'
11
- ];