-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Webpack emitted invalid ES module code, as it still contained `require` calls which are undefined on ES modules * Build time is much shorter * Built assets are much smaller (570 kB vs 930 kB) * Remove unneeded import Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
- Loading branch information
Showing
13 changed files
with
2,150 additions
and
1,078 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
const snapshot = require('./../src/functions/usernameToColor/__snapshots__/usernameToColor.spec.js.snap') | ||
const result = {} | ||
Object.keys(snapshot).map((key) => { | ||
const uid = key.replace('usernameToColor ', '').replace(' has the proper color 1', '') | ||
result[uid] = JSON.parse(snapshot[key]) | ||
const uid = key.replace('usernameToColor ', '').replace(' has the proper color 1', '') | ||
result[uid] = JSON.parse(snapshot[key]) | ||
}) | ||
console.log(JSON.stringify(result)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import type { Plugin } from 'vite' | ||
import { createLibConfig } from '@susnux/nextcloud-vite-config' | ||
import { resolve } from 'path' | ||
import { defineConfig } from 'vite' | ||
|
||
import md5 from 'md5' | ||
import * as url from 'url' | ||
|
||
import { loadTranslations } from './build/translations.js' | ||
|
||
// `__dirname` not available on ES modules by default | ||
const __dirname = url.fileURLToPath(new URL('.', import.meta.url)) | ||
|
||
const appVersion = JSON.stringify(process.env.npm_package_version || 'nextcloud-vue') | ||
const SCOPE_VERSION = md5(appVersion).slice(0, 7) as string | ||
const TRANSLATIONS = await loadTranslations(resolve(__dirname, './l10n')) | ||
|
||
// Entry points which we build using vite | ||
const entryPoints = { | ||
index: resolve(__dirname, 'src/index.js'), | ||
} | ||
|
||
// Plugin for stripping out <docs> sections from vue files | ||
const vueDocsPlugin: Plugin = { | ||
name: 'vue-docs-plugin', | ||
transform(code, id) { | ||
if (!/vue&type=doc/.test(id)) { | ||
return | ||
} | ||
return 'export default ""' | ||
}, | ||
} | ||
|
||
// Customizations for the vite config | ||
const overrides = defineConfig({ | ||
build: { | ||
// Vite is run second so do not remove webpack files | ||
emptyOutDir: false, | ||
}, | ||
plugins: [ | ||
vueDocsPlugin, | ||
], | ||
css: { | ||
devSourcemap: true, | ||
preprocessorOptions: { | ||
scss: { | ||
additionalData: `@use 'sass:math'; $scope_version:${SCOPE_VERSION}; @import 'variables'; @import 'material-icons';`, | ||
sourceMapContents: false, | ||
includePaths: [ | ||
resolve(__dirname, 'src/assets'), | ||
], | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
// We need a callback config so we can access the vite build mode | ||
export default defineConfig((env) => { | ||
|
||
const createConfig = createLibConfig(entryPoints, { | ||
// Add our overrides to the config | ||
config: overrides, | ||
// Packages with paths imports should be added here to mark them as external as well | ||
nodeExternalsOptions: { | ||
include: [/^vue-material-design-icons\//, /^@nextcloud\/l10n\//, /^@mdi\/svg\//], | ||
}, | ||
// For backwards compatibility we include the css within the js files | ||
inlineCSS: true, | ||
// Disable polyfills | ||
coreJS: false, | ||
replace: { | ||
PRODUCTION: JSON.stringify(env.mode === 'production'), | ||
SCOPE_VERSION, | ||
TRANSLATIONS: ';' + JSON.stringify(TRANSLATIONS), | ||
}, | ||
}) | ||
|
||
return createConfig(env) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters