Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Vite regressions #8099

Merged
merged 2 commits into from
Dec 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
],
"dependencies": {
"keycode": "^2.2.1",
"rollup-plugin-gzip": "^3.1.0",
"vite-plugin-static-copy": "^0.12.0",
"vite-plugin-treat-umd-as-commonjs": "0.1.3",
"vue": "2.7.14"
Expand Down
37 changes: 21 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 27 additions & 18 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import EnvironmentPlugin from 'vite-plugin-environment'
import { viteStaticCopy } from 'vite-plugin-static-copy'
import { treatAsCommonjs } from 'vite-plugin-treat-umd-as-commonjs'
import visualizer from 'rollup-plugin-visualizer'
import compression from 'rollup-plugin-gzip'

import ejs from 'ejs'
import { join } from 'path'
Expand Down Expand Up @@ -44,7 +45,7 @@ const input = readdirSync('packages').reduce(
{ 'index.html': 'index.html' }
)

export default defineConfig(({ mode }) => {
export default defineConfig(({ mode, command }) => {
const production = mode === 'production'
const ocis = process.env.OCIS !== 'false'
let config: UserConfigExport
Expand Down Expand Up @@ -170,24 +171,31 @@ export default defineConfig(({ mode }) => {
}
}),
viteStaticCopy({
targets: [
...['fonts', 'icons'].map((name) => ({
src: `packages/design-system/src/assets/${name}/*`,
dest: `${name}`
})),
{
src: `./packages/web-runtime/themes/*`,
dest: `themes`
},
{
src: `./config/vite_${configName}/*`,
dest: ``
},
{
src: 'node_modules/requirejs/require.js',
dest: 'js'
targets: (() => {
const targets = [
...['fonts', 'icons'].map((name) => ({
src: `packages/design-system/src/assets/${name}/*`,
dest: `${name}`
})),
{
src: `./packages/web-runtime/themes/*`,
dest: `themes`
},
{
src: 'node_modules/requirejs/require.js',
dest: 'js'
}
]

if (command === 'serve') {
targets.push({
src: `./config/vite_${configName}/*`,
dest: ``
})
}
]

return targets
})()
}),
{
name: '@ownclouders/vite-plugin-docs',
Expand Down Expand Up @@ -258,6 +266,7 @@ export default defineConfig(({ mode }) => {
}
}
},
compression(),
process.env.REPORT !== 'true'
? null
: visualizer({
Expand Down