import { defineConfig, loadEnv } from 'vite';
import react from "@vitejs/plugin-react";
import { sentryVitePlugin } from '@sentry/vite-plugin'
import { createHtmlPlugin } from 'vite-plugin-html';
import VitePluginReactRemoveAttributes from 'vite-plugin-react-remove-attributes';
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());
const plugins = [react()];
plugins.push(
sentryVitePlugin({
authToken: env.VITE_SENTRY_KEY,
org: env.VITE_SENTRY_ORG,
project: env.VITE_SENTRY_PROJECT,
telemetry: false,
sourcemaps: {
assets: './build/assets',
ignore: ['node_modules']
}
})
);
return {
build: {
outDir: 'build',
commonjsOptions: {
include: [/node_modules/, /types/],
},
sourcemap: true,
},
worker: {
format: 'es'
},
server: {
host: '127.0.0.1',
port: 3000
},
preview: {
host: true,
port: 3000,
strictPort: true
},
plugins: [
...plugins,
{
name: 'configure-response-headers',
configureServer: (server) => {
server.middlewares.use((_req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Strict-Transport-Security', 'max-age=31536000');
res.setHeader('X-Content-Type-Options', 'nosniff');
res.setHeader('Referrer-Policy', 'same-origin');
next();
});
},
},
createHtmlPlugin({
inject: {
data: {
RECAPTCHA_SITE_KEY: env.VITE_RECAPTCHA_SITE_KEY,
},
},
}),
...(env.VITE_E2E_ENVIRONMENT === 'true' ? [] : [
VitePluginReactRemoveAttributes({
attributes: ['data-testid'],
}),
]),
],
publicDir: 'public',
optimizeDeps: {
include: ['stb-common'],
},
};
});
Build is completed, release id is created and sourcemaps are sent.
client:build: cache miss, executing ed08942129d3851b
client:build:
client:build: > client@0.1.0 build /home/project/apps/client
client:build: > tsc --build tsconfig.build.json && vite build
client:build:
client:build: vite v4.4.10 building for production...
client:build: transforming...
client:build:
client:build: WARN src/constants.ts (1:8) Error when using sourcemap for reporting an error: Can't resolve original location of error.
client:build:
client:build: ✓ 4322 modules transformed.
client:build: ✓ built in 26.62s
client:build:
client:build: ERROR "Subscriptions" is not exported by "../common/types/dist/index.js", imported by "src/constants.ts".
client:build: file: /home/project/apps/client/src/constants.ts:1:8
client:build: 1: import {Subscriptions} from "stb-common";
client:build: ^
client:build: 2: import {NotificationsType} from "./store/Notifications";
client:build: 3: export const AXIOS_REQUEST_TIMEOUT = 1e4;
client:build:
client:build:
client:build: ERROR error during build:
client:build: RollupError: "Subscriptions" is not exported by "../common/types/dist/index.js", imported by "src/constants.ts".
client:build: at error (file:///home/project/apps/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:2287:30)
client:build: at Module.error (file:///home/project/apps/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:13745:16)
client:build: at Module.traceVariable (file:///home/project/apps/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:14175:29)
client:build: at ModuleScope.findVariable (file:///home/project/apps/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:12615:39)
client:build: at MemberExpression.bind (file:///home/project/apps/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:9539:49)
client:build: at Property.bind (file:///home/project/apps/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:5892:23)
client:build: at ObjectExpression.bind (file:///home/project/apps/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:5888:28)
client:build: at VariableDeclarator.bind (file:///home/project/apps/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:5892:23)
client:build: at VariableDeclaration.bind (file:///home/project/apps/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:5888:28)
client:build: at ExportNamedDeclaration.bind (file:///home/project/apps/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:10673:27)
client:build:
client:build: ELIFECYCLE Command failed with exit code 1.
client:build: ERROR: command finished with error: command (/home/project/apps/client) pnpm run build exited (1)
I'm trying to move from 0.4.0 to the 2.18.0 With previous version build is completed. Now I got this error. Am I missing something with the configuration? Without the plugin the build is complete without any issues...
Environment
"vite": "4.4.10" (same with 5.x)
"@sentry/vite-plugin": "2.18.0",
vite.config.ts
Steps to Reproduce
tsc --build tsconfig.build.json && vite buildExpected Result
Build is completed, release id is created and sourcemaps are sent.
Actual Result
I'm trying to move from 0.4.0 to the 2.18.0 With previous version build is completed. Now I got this error. Am I missing something with the configuration? Without the plugin the build is complete without any issues...