Skip to content

Commit

Permalink
Integrate plugin into vite config
Browse files Browse the repository at this point in the history
  • Loading branch information
WRadoslaw committed Aug 2, 2023
1 parent 8c6896d commit 1fbe4ad
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 69 deletions.
1 change: 1 addition & 0 deletions packages/atlas/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_SENTRY_AUTH_TOKEN=
6 changes: 2 additions & 4 deletions packages/atlas/src/api/axios/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import axios from 'axios'

export const axiosInstance = axios.create({
withCredentials: true,
})
export const axiosInstance = axios.create({})

axiosInstance.interceptors.response.use(
(response) => response,
Expand All @@ -11,6 +9,6 @@ axiosInstance.interceptors.response.use(
response.errorData = JSON.stringify(response.config.data)
}
response.endpoint = response.config.url
return response
throw response
}
)
141 changes: 76 additions & 65 deletions packages/atlas/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/// <reference types="vitest" />
import ViteYaml from '@modyfi/vite-plugin-yaml'
import babel from '@rollup/plugin-babel'
import { sentryVitePlugin } from '@sentry/vite-plugin'
import react from '@vitejs/plugin-react'
import * as path from 'node:path'
import { visualizer } from 'rollup-plugin-visualizer'
import { defineConfig } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import checker from 'vite-plugin-checker'

import {
Expand All @@ -16,74 +17,84 @@ import {
} from './plugins'

// https://vitejs.dev/config/
export default defineConfig({
root: './src',
build: {
target: ['chrome87', 'edge88', 'es2020', 'firefox78', 'safari14'],
emptyOutDir: true,
outDir: path.resolve(__dirname, 'dist'),
rollupOptions: {
input: {
main: path.resolve(__dirname, 'src/index.html'),
embedded: path.resolve(__dirname, 'src/embedded/index.html'),
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd())

return {
root: './src',
build: {
sourcemap: true,
target: ['chrome87', 'edge88', 'es2020', 'firefox78', 'safari14'],
emptyOutDir: true,
outDir: path.resolve(__dirname, 'dist'),
rollupOptions: {
input: {
main: path.resolve(__dirname, 'src/index.html'),
embedded: path.resolve(__dirname, 'src/embedded/index.html'),
},
},
},
},
server: {
port: 3000,
},
test: {
environment: 'happy-dom',
setupFiles: ['vitest-setup.ts'],
globals: true,
},
esbuild: {
logOverride: { 'this-is-undefined-in-esm': 'silent' }, // workaround for vite, esbuild and babel integration bug: https://github.com/vitejs/vite/issues/8644
},
worker: {
plugins: [PolkadotWorkerMetaFixPlugin],
},
plugins: [
AtlasHtmlMetaTagsPlugin,
AtlasWebmanifestPlugin,
EmbeddedFallbackPlugin,
OptimizePlugin,
ViteYaml(),
react({
exclude: /\.stories\.[tj]sx?$/,
}),
checker({
typescript: true,
eslint: {
lintCommand: 'eslint "./**/*.{js,jsx,ts,tsx}"',
dev: { overrideConfig: { ignorePath: '../.eslintignore' } },
},
overlay: false,
}),
babel({
extensions: ['.tsx', '.ts'],
include: ['**/*.style.*', '**/*.styles.*'],
plugins: ['@emotion'],
babelHelpers: 'bundled',
}),
{
...visualizer({
filename: 'dist/stats.html',
}),
enforce: 'post',
server: {
port: 3000,
},
test: {
environment: 'happy-dom',
setupFiles: ['vitest-setup.ts'],
globals: true,
},
esbuild: {
logOverride: { 'this-is-undefined-in-esm': 'silent' }, // workaround for vite, esbuild and babel integration bug: https://github.com/vitejs/vite/issues/8644
},
worker: {
plugins: [PolkadotWorkerMetaFixPlugin],
},
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
plugins: [
AtlasHtmlMetaTagsPlugin,
AtlasWebmanifestPlugin,
EmbeddedFallbackPlugin,
OptimizePlugin,
ViteYaml(),
sentryVitePlugin({
authToken: env.VITE_SENTRY_AUTH_TOKEN,
org: 'jsgenesis',
project: 'atlas',
}),
react({
exclude: /\.stories\.[tj]sx?$/,
}),
checker({
typescript: true,
eslint: {
lintCommand: 'eslint "./**/*.{js,jsx,ts,tsx}"',
dev: { overrideConfig: { ignorePath: '../.eslintignore' } },
},
overlay: false,
}),
babel({
extensions: ['.tsx', '.ts'],
include: ['**/*.style.*', '**/*.styles.*'],
plugins: ['@emotion'],
babelHelpers: 'bundled',
}),
{
...visualizer({
filename: 'dist/stats.html',
}),
enforce: 'post',
},
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
},
optimizeDeps: {
include: ['buffer'],
esbuildOptions: {
define: {
global: 'globalThis',
optimizeDeps: {
include: ['buffer'],
esbuildOptions: {
define: {
global: 'globalThis',
},
},
},
},
}
})

0 comments on commit 1fbe4ad

Please sign in to comment.