Skip to content

Commit

Permalink
Merge pull request #8099 from owncloud/vite-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann authored Dec 10, 2022
2 parents c9158b7 + 874a2bf commit 4f058fe
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 34 deletions.
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

0 comments on commit 4f058fe

Please sign in to comment.