Skip to content

Commit

Permalink
fix(npwd): fix building
Browse files Browse the repository at this point in the history
  • Loading branch information
itschip committed Nov 6, 2023
1 parent 85aefae commit f7d397d
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 37 deletions.
4 changes: 3 additions & 1 deletion apps/game/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ build({
write: true,
platform: 'browser',
target: 'es2016',
minify: true,
plugins: [
copy({
resolveFrom: 'cwd',
verbose: true,
copyOnStart: true,
assets: {
from: ['client/cl_controls.lua'],
to: ['../../dist/game/client/cl_controls.lua'],
to: ['../../dist/game/client/'],
},
}),
],
Expand Down
15 changes: 13 additions & 2 deletions apps/game/scripts/watch.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const { build } = require('esbuild');
const { copy } = require('esbuild-plugin-copy');

build({
entryPoints: ['server/server.ts'],
outfile: 'dist/server/server.js',
outfile: '../../dist/game/server/server.js',
bundle: true,
loader: {
'.ts': 'ts',
Expand All @@ -25,7 +26,7 @@ build({

build({
entryPoints: ['client/client.ts'],
outfile: 'dist/client/client.js',
outfile: '../../dist/game/client/client.js',
bundle: true,
loader: {
'.ts': 'ts',
Expand All @@ -40,6 +41,16 @@ build({
write: true,
platform: 'browser',
target: 'es2016',
plugins: [
copy({
resolveFrom: 'cwd',
verbose: true,
assets: {
from: ['client/cl_controls.lua'],
to: ['../../dist/game/client/cl_controls.lua'],
},
}),
],
})
.then(() => {
console.log('Client built successfully');
Expand Down
9 changes: 5 additions & 4 deletions apps/phone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"recoil": "^0.7.7",
"tailwind-merge": "^1.10.0",
"uuid": "^8.3.2",
"vite-plugin-top-level-await": "^1.3.1",
"xss": "^1.0.13"
},
"devDependencies": {
Expand Down Expand Up @@ -83,10 +84,10 @@
},
"scripts": {
"i18n:missing": "node --experimental-json-modules i18n.missingKeys.js",
"dev:old": "cross-env IS_BROWSER_DEV=1 webpack serve --config config/webpack.dev.js --mode development",
"dev": "cross-env VITE_REACT_APP_IN_GAME=false vite",
"build": "webpack --config config/webpack.production.js --mode production --progress --color",
"dev:game": "cross-env REACT_APP_IN_GAME=1 BROWSER=none webpack --config config/webpack.dev.js --mode development --watch --progress"
"dev": "vite --mode dev",
"dev:game": "BROWSER=none build:watch",
"build": "vite build --mode game",
"build:watch": "vite build --watch --mode game"
},
"eslintConfig": {
"extends": "react-app"
Expand Down
4 changes: 2 additions & 2 deletions apps/phone/src/os/apps/hooks/useApps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ export const useApps = () => {
const apps: IApp[] = useMemo(() => {
return APPS.map((app) => {
const SvgIcon = React.lazy<SvgIconComponent>(() =>
import(`../icons/${curIconSet.name}/svg/${app.id}`).catch(
import(`../icons/${curIconSet.name}/svg/${app.id}.tsx`).catch(
() => 'Was not able to find a dynamic import for icon from this icon set',
),
);
const AppIcon = React.lazy<SvgIconComponent>(() =>
import(`../icons/${curIconSet.name}/app/${app.id}`).catch(
import(`../icons/${curIconSet.name}/app/${app.id}.tsx`).catch(
() => 'Was not able to find a dynamic import for icon from this icon set',
),
);
Expand Down
13 changes: 12 additions & 1 deletion apps/phone/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';

import topLevelAwait from 'vite-plugin-top-level-await'
import federation from '@originjs/vite-plugin-federation';

// https://vitejs.dev/config/
Expand All @@ -12,6 +12,12 @@ export default defineConfig({
remotes: { dummyRemote: 'dummyRemote.js' },
shared: ['react', 'react-dom', '@emotion/react', 'react-router-dom'],
}),
topLevelAwait({
// The export name of top-level await promise for each chunk module
promiseExportName: "__tla",
// The function to generate import names of top-level await promise in each chunk module
promiseImportName: i => `__tla_${i}`
})
],
server: {
port: 3000,
Expand All @@ -30,4 +36,9 @@ export default defineConfig({
define: {
'process.env': {},
},
base: "./",
build: {
emptyOutDir: true,
outDir: "../../dist/html"
}
});
Loading

0 comments on commit f7d397d

Please sign in to comment.