Skip to content

Commit

Permalink
refactor: migrate react-script to vite for hello-world-bot-with tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Yimin-Jin committed Sep 19, 2024
1 parent b511fbb commit 83ad60d
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 30 deletions.
2 changes: 1 addition & 1 deletion hello-world-bot-with-tab/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"background": {
"activeOnStart": true,
"beginsPattern": ".*",
"endsPattern": "Compiled|Failed|compiled|failed"
"endsPattern": "Compiled|Failed|compiled|failed|ready"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="icon" href="/favicon.ico" />
<link
rel="stylesheet"
href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-core/11.0.0/css/fabric.min.css"
Expand All @@ -13,5 +13,6 @@
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
16 changes: 9 additions & 7 deletions hello-world-bot-with-tab/tab/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,25 @@
"axios": "^1.6.7",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.8.0",
"react-scripts": "^5.0.1"
"react-router-dom": "^6.8.0"
},
"devDependencies": {
"@types/node": "^14.0.0",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"@types/react-router-dom": "^5.3.3",
"env-cmd": "^10.1.0",
"typescript": "^4.1.2"
"typescript": "^4.1.2",
"vite": "^5.4.2",
"@vitejs/plugin-basic-ssl": "^1.1.0",
"@vitejs/plugin-react": "^4.3.1"
},
"scripts": {
"dev:teamsfx": "env-cmd --silent -f .localConfigs npm run start",
"start": "react-scripts start",
"build": "react-scripts build",
"eject": "react-scripts eject",
"test": "echo \"Error: no test specified\" && exit 1"
"start": "vite",
"build": "tsc && vite build",
"test": "echo \"Error: no test specified\" && exit 1",
"serve": "vite preview"
},
"eslintConfig": {
"extends": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";

export function EditCode(props: { tabCodeEntry?: string }) {
const { tabCodeEntry } = {
tabCodeEntry: "tabs/src/index.tsx",
tabCodeEntry: "tab/src/index.tsx",
...props,
};
return (
Expand Down
24 changes: 24 additions & 0 deletions hello-world-bot-with-tab/tab/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"]
}
25 changes: 6 additions & 19 deletions hello-world-bot-with-tab/tab/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src"]
}
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}
22 changes: 22 additions & 0 deletions hello-world-bot-with-tab/tab/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["vite.config.ts"]
}
14 changes: 14 additions & 0 deletions hello-world-bot-with-tab/tab/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import fs from "fs";

export default defineConfig({
plugins: [react()],
server: {
port: 53000,
https: {
cert: process.env.SSL_CRT_FILE ? fs.readFileSync(process.env.SSL_CRT_FILE) : undefined,
key: process.env.SSL_KEY_FILE ? fs.readFileSync(process.env.SSL_KEY_FILE) : undefined,
},
},
});
2 changes: 1 addition & 1 deletion hello-world-bot-with-tab/teamsapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ deploy:
- uses: cli/runNpxCommand
name: deploy to Azure Static Web Apps
with:
args: '@azure/static-web-apps-cli deploy ./tab/build -d
args: '@azure/static-web-apps-cli deploy ./tab/dist -d
${{SECRET_TAB_SWA_DEPLOYMENT_TOKEN}} --env production'
# Deploy your application to Azure App Service using the zip deploy feature.
# For additional details, refer to https://aka.ms/zip-deploy-to-app-services.
Expand Down

0 comments on commit 83ad60d

Please sign in to comment.