Skip to content

Commit

Permalink
feat:#85 Google插件扩展-基本适配
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Sep 20, 2022
1 parent 72472db commit 61ce753
Show file tree
Hide file tree
Showing 3 changed files with 281 additions and 63 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"vbuild": "vercel build"
},
"dependencies": {
"@intlify/vite-plugin-vue-i18n": "^6.0.1",
"@octokit/core": "^4.0.4",
"copy-to-clipboard": "^3.3.1",
"cross-fetch": "^3.1.5",
Expand All @@ -30,7 +31,7 @@
"transliteration": "^2.3.5",
"uuid": "^8.3.2",
"vue": "^3.2.37",
"vue-i18n": "9",
"vue-i18n": "^9.2.2",
"xmlrpc": "^1.3.2"
},
"devDependencies": {
Expand Down
15 changes: 13 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import {defineConfig} from 'vite'
import {loadEnv} from "vite";
import { resolve, dirname } from 'node:path'
import { fileURLToPath } from 'url'
import vue from '@vitejs/plugin-vue'
import vitePluginRequireTransform from 'vite-plugin-require-transform';
import {NodeGlobalsPolyfillPlugin} from '@esbuild-plugins/node-globals-polyfill'
import {NodeModulesPolyfillPlugin} from '@esbuild-plugins/node-modules-polyfill'
// You don't need to add this to deps, it's included by @esbuild-plugins/node-modules-polyfill
import rollupNodePolyFill from 'rollup-plugin-node-polyfills'
// @ts-ignore
import vueI18n from '@intlify/vite-plugin-vue-i18n'

// https://vitejs.dev/config/
export default defineConfig(({mode}) => {
const env = loadEnv(mode, process.cwd())

const processEnvValues = {
'process.env': Object.entries(env).reduce(
(prev, [key, val]) => {
Expand All @@ -22,6 +25,7 @@ export default defineConfig(({mode}) => {
{},
)
}
console.log(env.DEV)

return {
plugins: [
Expand All @@ -31,6 +35,12 @@ export default defineConfig(({mode}) => {
vitePluginRequireTransform.default({
fileRegex: /.ts$|.vue$/
}),
vueI18n({
// if you want to use Vue I18n Legacy API, you need to set `compositionOnly: false`
// compositionOnly: false,
// you need to set i18n resource including paths !
include: resolve(dirname(fileURLToPath(import.meta.url)), 'src/locales/index.ts'),
})
],
base: './',
// https://github.com/vitejs/vite/issues/1930
Expand All @@ -39,7 +49,8 @@ export default defineConfig(({mode}) => {
define: Object.assign(processEnvValues, {}),
resolve: {
alias: {
'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js',
// 'vue-i18n': 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js',
// 'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js',
'node-fetch': 'cross-fetch',
// This Rollup aliases are extracted from @esbuild-plugins/node-modules-polyfill,
// see https://github.com/remorses/esbuild-plugins/blob/master/node-modules-polyfill/src/polyfills.ts
Expand Down
Loading

0 comments on commit 61ce753

Please sign in to comment.