add hosted for online demo

This commit is contained in:
Proddy
2023-02-09 22:41:47 +01:00
parent 1cd980f46a
commit d0f91c5f43
3 changed files with 36 additions and 28 deletions

1
.gitignore vendored
View File

@@ -6,6 +6,7 @@
# build # build
build/ build/
dist/
.clang_complete .clang_complete
.gcc-flags.json .gcc-flags.json
cppcheck.out.xml cppcheck.out.xml

View File

@@ -5,8 +5,9 @@
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "tsc && vite build", "build": "tsc && vite build",
"build-hosted": "tsc && vite build --mode hosted",
"preview": "vite preview", "preview": "vite preview",
"preview_standalone": "npm-run-all -p preview typesafe-i18n mock-api", "preview-standalone": "npm-run-all -p preview typesafe-i18n mock-api",
"mock-api": "nodemon --watch ../mock-api ../mock-api/server.js", "mock-api": "nodemon --watch ../mock-api ../mock-api/server.js",
"standalone": "npm-run-all -p dev typesafe-i18n mock-api", "standalone": "npm-run-all -p dev typesafe-i18n mock-api",
"typesafe-i18n": "typesafe-i18n", "typesafe-i18n": "typesafe-i18n",

View File

@@ -5,33 +5,39 @@ import svgrPlugin from 'vite-plugin-svgr';
import { visualizer } from 'rollup-plugin-visualizer'; import { visualizer } from 'rollup-plugin-visualizer';
import ProgmemGenerator from './progmem-generator'; import ProgmemGenerator from './progmem-generator';
export default defineConfig({ export default defineConfig(({ command, mode }) => {
plugins: [ if (mode === 'hosted') {
react({ plugins: [['@swc/plugin-styled-components', {}]] }), return {
viteTsconfigPaths(), // hosted, ignore all errors, output to dist
svgrPlugin(), plugins: [react({ plugins: [['@swc/plugin-styled-components', {}]] }), viteTsconfigPaths(), svgrPlugin()]
ProgmemGenerator({ outputPath: '../lib/framework/WWWData.h', bytesPerLine: 20 }), };
visualizer({ gzipSize: true }) as PluginOption } else {
], // normal build
// root: 'src', return {
base: '/', plugins: [
// publicDir: "./public", react({ plugins: [['@swc/plugin-styled-components', {}]] }),
build: { viteTsconfigPaths(),
// Relative to the root svgrPlugin(),
outDir: 'build', ProgmemGenerator({ outputPath: '../lib/framework/WWWData.h', bytesPerLine: 20 }),
chunkSizeWarningLimit: 1024 visualizer({ gzipSize: true }) as PluginOption
}, ],
server: { build: {
open: true, outDir: 'build',
port: 3000, chunkSizeWarningLimit: 1024
proxy: { },
'/rest': 'http://localhost:3080', server: {
'/api': { open: true,
target: 'http://localhost:3080', port: 3000,
changeOrigin: true, proxy: {
secure: false, '/rest': 'http://localhost:3080',
ws: true '/api': {
target: 'http://localhost:3080',
changeOrigin: true,
secure: false,
ws: true
}
}
} }
} };
} }
}); });