Skip to content

Commit

Permalink
WORKING
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtatranta committed Feb 21, 2025
1 parent 1fb85ff commit ab227b5
Showing 1 changed file with 38 additions and 15 deletions.
53 changes: 38 additions & 15 deletions packages/suite-web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,32 @@ import { viteCommonjs } from '@originjs/vite-plugin-commonjs';
import react from '@vitejs/plugin-react';

Check failure on line 2 in packages/suite-web/vite.config.ts

View workflow job for this annotation

GitHub Actions / Linting and formatting

'@vitejs/plugin-react' should be listed in the project's dependencies, not devDependencies
import { readdirSync } from 'fs';
import { resolve } from 'path';
import { defineConfig } from 'vite';
import { build, defineConfig } from 'vite';

Check failure on line 5 in packages/suite-web/vite.config.ts

View workflow job for this annotation

GitHub Actions / Linting and formatting

'vite' should be listed in the project's dependencies, not devDependencies

Check failure on line 5 in packages/suite-web/vite.config.ts

View workflow job for this annotation

GitHub Actions / Linting and formatting

'build' is defined but never used. Allowed unused vars must match /^_/u

import { assetPrefix, isDev, project } from '../suite-build/utils/env';

Check failure on line 7 in packages/suite-web/vite.config.ts

View workflow job for this annotation

GitHub Actions / Linting and formatting

'isDev' is defined but never used. Allowed unused vars must match /^_/u

// Plugin to serve core.js in dev mode
const serveCorePlugin = () => ({
name: 'serve-core',
configureServer(server) {
server.middlewares.use(async (req, res, next) => {
if (req.url?.endsWith('/js/core.js')) {
const code = await server.transformRequest(
resolve(__dirname, '../connect/src/core/index.ts'),
{ ssr: false },
);
if (code?.code) {
res.setHeader('Content-Type', 'application/javascript');
res.end(code.code);

return;
}
}
next();
});
},
});

// This helper creates aliases for all workspace packages
const createWorkspaceAliases = () => {
const suiteCommonAliases = Object.fromEntries(
Expand Down Expand Up @@ -33,6 +55,7 @@ export default defineConfig({
root: '.',
base: assetPrefix,
plugins: [
serveCorePlugin(),
viteCommonjs(),
react({
babel: {
Expand All @@ -52,7 +75,7 @@ export default defineConfig({
alias: [
{
find: /^@trezor\/connect(\/index)?$/,
replacement: '@trezor/connect-web/src/module'
replacement: '@trezor/connect-web/src/module',
},
{
find: 'src',
Expand All @@ -79,19 +102,19 @@ export default defineConfig({
// Polyfill Node.js globals
global: 'globalThis',
},
build: {
outDir: 'build',
sourcemap: true,
rollupOptions: {
input: {
main: resolve(__dirname, 'src/index.ts'),
},
},
commonjsOptions: {
transformMixedEsModules: true,
include: [/node_modules/, /packages/],
},
},
// build: {
// outDir: 'build',
// sourcemap: true,
// rollupOptions: {
// input: {
// main: resolve(__dirname, 'src/index.ts'),
// },
// },
// commonjsOptions: {
// transformMixedEsModules: true,
// include: [/node_modules/, /packages/],
// },
// },
optimizeDeps: {
include: ['@trezor/connect', '@trezor/suite'],
esbuildOptions: {
Expand Down

0 comments on commit ab227b5

Please sign in to comment.