@salesforce/templates 65.2.0 → 65.4.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/lib/generators/webApplicationGenerator.d.ts +3 -0
- package/lib/generators/webApplicationGenerator.js +44 -3
- package/lib/generators/webApplicationGenerator.js.map +1 -1
- package/lib/templates/reactbasic/index.html +12 -0
- package/lib/templates/reactbasic/package.json +32 -0
- package/lib/templates/reactbasic/postcss.config.js +7 -0
- package/lib/templates/reactbasic/src/App.tsx +25 -0
- package/lib/templates/reactbasic/src/components/Navigation.tsx +70 -0
- package/lib/templates/reactbasic/src/main.tsx +14 -0
- package/lib/templates/reactbasic/src/pages/About.tsx +13 -0
- package/lib/templates/reactbasic/src/pages/Home.tsx +15 -0
- package/lib/templates/reactbasic/src/pages/NotFound.tsx +21 -0
- package/lib/templates/reactbasic/src/routes.ts +20 -0
- package/lib/templates/reactbasic/src/styles/global.css +10 -0
- package/lib/templates/reactbasic/src/test-setup/setup.ts +10 -0
- package/lib/templates/reactbasic/src/vite-env.d.ts +2 -0
- package/lib/templates/reactbasic/tailwind.config.js +9 -0
- package/lib/templates/reactbasic/tsconfig.json +29 -0
- package/lib/templates/reactbasic/tsconfig.node.json +14 -0
- package/lib/templates/reactbasic/vite.config.ts +36 -0
- package/lib/templates/reactbasic/webapp.json +17 -0
- package/lib/utils/types.d.ts +1 -1
- package/package.json +1 -1
- /package/lib/templates/{webapp-basic → webappbasic}/_webapplication.webApplication-meta.xml +0 -0
- /package/lib/templates/{webapp-basic/default.html → webappbasic/index.html} +0 -0
- /package/lib/templates/{webapp-basic → webappbasic}/webapp.json +0 -0
|
@@ -4,4 +4,7 @@ export default class WebApplicationGenerator extends BaseGenerator<WebApplicatio
|
|
|
4
4
|
constructor(options: WebApplicationOptions);
|
|
5
5
|
validateOptions(): void;
|
|
6
6
|
generate(): Promise<void>;
|
|
7
|
+
private generateSharedMetadata;
|
|
8
|
+
private generateWebAppBasic;
|
|
9
|
+
private generateReactBasic;
|
|
7
10
|
}
|
|
@@ -27,14 +27,55 @@ class WebApplicationGenerator extends baseGenerator_1.BaseGenerator {
|
|
|
27
27
|
generate() {
|
|
28
28
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
29
29
|
const { template, webappname } = this.options;
|
|
30
|
+
const normalizedTemplate = template.toLowerCase();
|
|
30
31
|
const masterLabel = this.options.masterlabel || (0, kit_1.camelCaseToTitleCase)(webappname);
|
|
31
|
-
this.sourceRootWithPartialPath('webapp-basic');
|
|
32
32
|
const webappDir = path.join(this.outputdir, webappname);
|
|
33
|
-
yield this.
|
|
34
|
-
|
|
33
|
+
yield this.generateSharedMetadata(webappDir, webappname, masterLabel);
|
|
34
|
+
switch (normalizedTemplate) {
|
|
35
|
+
case 'reactbasic':
|
|
36
|
+
yield this.generateReactBasic(webappDir, webappname, masterLabel);
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
yield this.generateWebAppBasic(webappDir, masterLabel);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
generateSharedMetadata(webappDir, webappname, masterLabel) {
|
|
44
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
this.sourceRootWithPartialPath('webappbasic');
|
|
35
46
|
yield this.render(this.templatePath('_webapplication.webApplication-meta.xml'), this.destinationPath(path.join(webappDir, `${webappname}.webApplication-meta.xml`)), { apiVersion: this.apiversion, masterLabel });
|
|
36
47
|
});
|
|
37
48
|
}
|
|
49
|
+
generateWebAppBasic(webappDir, masterLabel) {
|
|
50
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
this.sourceRootWithPartialPath('webappbasic');
|
|
52
|
+
yield this.render(this.templatePath('index.html'), this.destinationPath(path.join(webappDir, 'index.html')), { masterLabel });
|
|
53
|
+
yield this.render(this.templatePath('webapp.json'), this.destinationPath(path.join(webappDir, 'webapp.json')), {});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
generateReactBasic(webappDir, webappname, masterLabel) {
|
|
57
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
this.sourceRootWithPartialPath('reactbasic');
|
|
59
|
+
yield this.render(this.templatePath('index.html'), this.destinationPath(path.join(webappDir, 'index.html')), { masterLabel });
|
|
60
|
+
yield this.render(this.templatePath('webapp.json'), this.destinationPath(path.join(webappDir, 'webapp.json')), {});
|
|
61
|
+
yield this.render(this.templatePath('package.json'), this.destinationPath(path.join(webappDir, 'package.json')), { webappname });
|
|
62
|
+
yield this.render(this.templatePath('vite.config.ts'), this.destinationPath(path.join(webappDir, 'vite.config.ts')), {});
|
|
63
|
+
yield this.render(this.templatePath('tsconfig.json'), this.destinationPath(path.join(webappDir, 'tsconfig.json')), {});
|
|
64
|
+
yield this.render(this.templatePath('tsconfig.node.json'), this.destinationPath(path.join(webappDir, 'tsconfig.node.json')), {});
|
|
65
|
+
yield this.render(this.templatePath('tailwind.config.js'), this.destinationPath(path.join(webappDir, 'tailwind.config.js')), {});
|
|
66
|
+
yield this.render(this.templatePath('postcss.config.js'), this.destinationPath(path.join(webappDir, 'postcss.config.js')), {});
|
|
67
|
+
yield this.render(this.templatePath(path.join('src', 'main.tsx')), this.destinationPath(path.join(webappDir, 'src', 'main.tsx')), {});
|
|
68
|
+
yield this.render(this.templatePath(path.join('src', 'App.tsx')), this.destinationPath(path.join(webappDir, 'src', 'App.tsx')), {});
|
|
69
|
+
yield this.render(this.templatePath(path.join('src', 'routes.ts')), this.destinationPath(path.join(webappDir, 'src', 'routes.ts')), {});
|
|
70
|
+
yield this.render(this.templatePath(path.join('src', 'vite-env.d.ts')), this.destinationPath(path.join(webappDir, 'src', 'vite-env.d.ts')), {});
|
|
71
|
+
yield this.render(this.templatePath(path.join('src', 'components', 'Navigation.tsx')), this.destinationPath(path.join(webappDir, 'src', 'components', 'Navigation.tsx')), {});
|
|
72
|
+
yield this.render(this.templatePath(path.join('src', 'pages', 'Home.tsx')), this.destinationPath(path.join(webappDir, 'src', 'pages', 'Home.tsx')), {});
|
|
73
|
+
yield this.render(this.templatePath(path.join('src', 'pages', 'About.tsx')), this.destinationPath(path.join(webappDir, 'src', 'pages', 'About.tsx')), {});
|
|
74
|
+
yield this.render(this.templatePath(path.join('src', 'pages', 'NotFound.tsx')), this.destinationPath(path.join(webappDir, 'src', 'pages', 'NotFound.tsx')), {});
|
|
75
|
+
yield this.render(this.templatePath(path.join('src', 'styles', 'global.css')), this.destinationPath(path.join(webappDir, 'src', 'styles', 'global.css')), {});
|
|
76
|
+
yield this.render(this.templatePath(path.join('src', 'test-setup', 'setup.ts')), this.destinationPath(path.join(webappDir, 'src', 'test-setup', 'setup.ts')), {});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
38
79
|
}
|
|
39
80
|
exports.default = WebApplicationGenerator;
|
|
40
81
|
//# sourceMappingURL=webApplicationGenerator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webApplicationGenerator.js","sourceRoot":"","sources":["../../src/generators/webApplicationGenerator.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,yCAAuD;AACvD,6BAA6B;AAC7B,kCAA8B;AAC9B,oCAAsC;AAEtC,mDAAgD;AAEhD,MAAqB,uBAAwB,SAAQ,6BAAoC;IACvF,YAAY,OAA8B;QACxC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAEM,eAAe;QACpB,kBAAU,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAChD,kBAAU,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAE9C,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/D,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,SAAS,CAAC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CAAC,CACrD,EACD,EAAE,CACH,CAAC;YAEF,MAAM,IAAI,CAAC,MAAM,CACf,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,EAC3D,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,EACzE,EAAE,CACH,CAAC;YAEF,MAAM,IAAI,CAAC,MAAM,CACf,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC,EAC7D,IAAI,CAAC,eAAe,CAClB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,CAAC,CACtD,EACD,EAAE,CACH,CAAC;QACJ,CAAC;KAAA;CACF;AAnLD,0CAmLC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title><%= masterLabel %></title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "<%= webappname %>",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite --mode development",
|
|
8
|
+
"build": "tsc && vite build",
|
|
9
|
+
"preview": "vite preview",
|
|
10
|
+
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
|
|
11
|
+
"test": "vitest run --passWithNoTests"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"react": "^18.3.1",
|
|
15
|
+
"react-dom": "^18.3.1",
|
|
16
|
+
"react-router-dom": "^6.28.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/react": "^18.3.12",
|
|
20
|
+
"@types/react-dom": "^18.3.1",
|
|
21
|
+
"@vitejs/plugin-react": "^4.3.3",
|
|
22
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
23
|
+
"@testing-library/react": "^16.1.0",
|
|
24
|
+
"autoprefixer": "^10.4.20",
|
|
25
|
+
"postcss": "^8.4.49",
|
|
26
|
+
"tailwindcss": "^3.4.17",
|
|
27
|
+
"typescript": "^5.2.2",
|
|
28
|
+
"vite": "^7.0.0",
|
|
29
|
+
"vitest": "^4.0.6"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Routes, Route } from 'react-router-dom';
|
|
2
|
+
import Navigation from './components/Navigation';
|
|
3
|
+
import { routes } from './routes';
|
|
4
|
+
|
|
5
|
+
function App() {
|
|
6
|
+
return (
|
|
7
|
+
<div className="min-h-screen flex flex-col">
|
|
8
|
+
<Navigation />
|
|
9
|
+
<main className="flex-1">
|
|
10
|
+
<Routes>
|
|
11
|
+
{routes.map(route => (
|
|
12
|
+
<Route
|
|
13
|
+
key={route.path}
|
|
14
|
+
path={route.path}
|
|
15
|
+
element={<route.component />}
|
|
16
|
+
/>
|
|
17
|
+
))}
|
|
18
|
+
</Routes>
|
|
19
|
+
</main>
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default App;
|
|
25
|
+
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { Link, useLocation } from 'react-router-dom';
|
|
3
|
+
import { navItems } from '../routes';
|
|
4
|
+
|
|
5
|
+
function Navigation() {
|
|
6
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
7
|
+
const location = useLocation();
|
|
8
|
+
|
|
9
|
+
const isActive = (path: string) => location.pathname === path;
|
|
10
|
+
|
|
11
|
+
const toggleMenu = () => setIsOpen(!isOpen);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<nav className="bg-white border-b border-gray-200">
|
|
15
|
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
|
16
|
+
<div className="flex justify-between items-center h-16">
|
|
17
|
+
<Link to="/" className="text-xl font-semibold text-gray-900">
|
|
18
|
+
React App
|
|
19
|
+
</Link>
|
|
20
|
+
<button
|
|
21
|
+
onClick={toggleMenu}
|
|
22
|
+
className="p-2 rounded-md text-gray-700 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
23
|
+
aria-label="Toggle menu"
|
|
24
|
+
>
|
|
25
|
+
<div className="w-6 h-6 flex flex-col justify-center space-y-1.5">
|
|
26
|
+
<span
|
|
27
|
+
className={`block h-0.5 w-6 bg-current transition-all ${
|
|
28
|
+
isOpen ? 'rotate-45 translate-y-2' : ''
|
|
29
|
+
}`}
|
|
30
|
+
/>
|
|
31
|
+
<span
|
|
32
|
+
className={`block h-0.5 w-6 bg-current transition-all ${
|
|
33
|
+
isOpen ? 'opacity-0' : ''
|
|
34
|
+
}`}
|
|
35
|
+
/>
|
|
36
|
+
<span
|
|
37
|
+
className={`block h-0.5 w-6 bg-current transition-all ${
|
|
38
|
+
isOpen ? '-rotate-45 -translate-y-2' : ''
|
|
39
|
+
}`}
|
|
40
|
+
/>
|
|
41
|
+
</div>
|
|
42
|
+
</button>
|
|
43
|
+
</div>
|
|
44
|
+
{isOpen && (
|
|
45
|
+
<div className="pb-4">
|
|
46
|
+
<div className="flex flex-col space-y-2">
|
|
47
|
+
{navItems.map(item => (
|
|
48
|
+
<Link
|
|
49
|
+
key={item.path}
|
|
50
|
+
to={item.path}
|
|
51
|
+
onClick={() => setIsOpen(false)}
|
|
52
|
+
className={`px-3 py-2 rounded-md text-sm font-medium transition-colors ${
|
|
53
|
+
isActive(item.path)
|
|
54
|
+
? 'bg-blue-100 text-blue-700'
|
|
55
|
+
: 'text-gray-700 hover:bg-gray-100'
|
|
56
|
+
}`}
|
|
57
|
+
>
|
|
58
|
+
{item.label}
|
|
59
|
+
</Link>
|
|
60
|
+
))}
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
)}
|
|
64
|
+
</div>
|
|
65
|
+
</nav>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default Navigation;
|
|
70
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom/client';
|
|
3
|
+
import { BrowserRouter } from 'react-router-dom';
|
|
4
|
+
import App from './App';
|
|
5
|
+
import './styles/global.css';
|
|
6
|
+
|
|
7
|
+
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
8
|
+
<React.StrictMode>
|
|
9
|
+
<BrowserRouter>
|
|
10
|
+
<App />
|
|
11
|
+
</BrowserRouter>
|
|
12
|
+
</React.StrictMode>
|
|
13
|
+
);
|
|
14
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function About() {
|
|
2
|
+
return (
|
|
3
|
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
|
|
4
|
+
<div className="text-center">
|
|
5
|
+
<h1 className="text-4xl font-bold text-gray-900 mb-4">About</h1>
|
|
6
|
+
<p className="text-lg text-gray-600">This is the about page.</p>
|
|
7
|
+
</div>
|
|
8
|
+
</div>
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default About;
|
|
13
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function Home() {
|
|
2
|
+
return (
|
|
3
|
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
|
|
4
|
+
<div className="text-center">
|
|
5
|
+
<h1 className="text-4xl font-bold text-gray-900 mb-4">Home</h1>
|
|
6
|
+
<p className="text-lg text-gray-600 mb-8">
|
|
7
|
+
Welcome to your React application.
|
|
8
|
+
</p>
|
|
9
|
+
</div>
|
|
10
|
+
</div>
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default Home;
|
|
15
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Link } from 'react-router-dom';
|
|
2
|
+
|
|
3
|
+
function NotFound() {
|
|
4
|
+
return (
|
|
5
|
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
|
|
6
|
+
<div className="text-center">
|
|
7
|
+
<h1 className="text-4xl font-bold text-gray-900 mb-4">404</h1>
|
|
8
|
+
<p className="text-lg text-gray-600 mb-8">Page not found</p>
|
|
9
|
+
<Link
|
|
10
|
+
to="/"
|
|
11
|
+
className="inline-block px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors"
|
|
12
|
+
>
|
|
13
|
+
Go to Home
|
|
14
|
+
</Link>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default NotFound;
|
|
21
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import Home from './pages/Home';
|
|
3
|
+
import About from './pages/About';
|
|
4
|
+
import NotFound from './pages/NotFound';
|
|
5
|
+
|
|
6
|
+
export interface RouteConfig {
|
|
7
|
+
path: string;
|
|
8
|
+
label: string;
|
|
9
|
+
component: ComponentType;
|
|
10
|
+
showInNav?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const routes: RouteConfig[] = [
|
|
14
|
+
{ path: '/', label: 'Home', component: Home, showInNav: true },
|
|
15
|
+
{ path: '/about', label: 'About', component: About, showInNav: true },
|
|
16
|
+
{ path: '*', label: 'Not Found', component: NotFound, showInNav: false },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
export const navItems = routes.filter(route => route.showInNav);
|
|
20
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"moduleResolution": "bundler",
|
|
9
|
+
"allowImportingTsExtensions": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"jsx": "react-jsx",
|
|
14
|
+
"strict": true,
|
|
15
|
+
"noUnusedLocals": true,
|
|
16
|
+
"noUnusedParameters": true,
|
|
17
|
+
"noFallthroughCasesInSwitch": true,
|
|
18
|
+
"baseUrl": ".",
|
|
19
|
+
"paths": {
|
|
20
|
+
"@/*": ["./src/*"],
|
|
21
|
+
"@components/*": ["./src/components/*"],
|
|
22
|
+
"@pages/*": ["./src/pages/*"],
|
|
23
|
+
"@styles/*": ["./src/styles/*"]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"include": ["src"],
|
|
27
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
|
28
|
+
}
|
|
29
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"composite": true,
|
|
4
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
5
|
+
"skipLibCheck": true,
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"moduleResolution": "bundler",
|
|
8
|
+
"allowSyntheticDefaultImports": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"outDir": "./build"
|
|
11
|
+
},
|
|
12
|
+
"include": ["vite.config.ts"]
|
|
13
|
+
}
|
|
14
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { resolve } from 'path';
|
|
5
|
+
|
|
6
|
+
export default defineConfig(() => {
|
|
7
|
+
return {
|
|
8
|
+
plugins: [react()],
|
|
9
|
+
base: '/',
|
|
10
|
+
|
|
11
|
+
resolve: {
|
|
12
|
+
alias: {
|
|
13
|
+
'@': path.resolve(__dirname, './src'),
|
|
14
|
+
'@components': path.resolve(__dirname, './src/components'),
|
|
15
|
+
'@pages': path.resolve(__dirname, './src/pages'),
|
|
16
|
+
'@styles': path.resolve(__dirname, './src/styles'),
|
|
17
|
+
},
|
|
18
|
+
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
build: {
|
|
22
|
+
outDir: resolve(__dirname, 'dist'),
|
|
23
|
+
assetsDir: 'assets',
|
|
24
|
+
sourcemap: false,
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
test: {
|
|
28
|
+
root: resolve(__dirname),
|
|
29
|
+
environment: 'happy-dom',
|
|
30
|
+
setupFiles: ['./src/test-setup/setup.ts'],
|
|
31
|
+
include: ['src/**/*.{test,spec}.{js,ts,jsx,tsx}'],
|
|
32
|
+
exclude: ['node_modules/', 'dist/'],
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"outputDir": "dist",
|
|
3
|
+
"scripts": {
|
|
4
|
+
"dev": "npm run dev",
|
|
5
|
+
"build": "npm run build",
|
|
6
|
+
"previewUrl": "http://localhost:3000"
|
|
7
|
+
},
|
|
8
|
+
"routing": {
|
|
9
|
+
"rewrites": [
|
|
10
|
+
{ "route": "/app/*", "rewrite": "pages/index.html" }
|
|
11
|
+
],
|
|
12
|
+
"redirects": [],
|
|
13
|
+
"fallback": "pages/index.html",
|
|
14
|
+
"trailingSlash": "auto",
|
|
15
|
+
"fileBasedRouting": true
|
|
16
|
+
}
|
|
17
|
+
}
|
package/lib/utils/types.d.ts
CHANGED
|
@@ -119,7 +119,7 @@ export interface StaticResourceOptions extends TemplateOptions {
|
|
|
119
119
|
}
|
|
120
120
|
export interface WebApplicationOptions extends TemplateOptions {
|
|
121
121
|
webappname: string;
|
|
122
|
-
template:
|
|
122
|
+
template: string;
|
|
123
123
|
masterlabel?: string;
|
|
124
124
|
internal?: boolean;
|
|
125
125
|
}
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|