Skip to content

Commit

Permalink
🐛fix(build): worker打包路径出错,自动导入样式
Browse files Browse the repository at this point in the history
  • Loading branch information
Ten-K committed Aug 29, 2022
1 parent 023c330 commit 6926168
Show file tree
Hide file tree
Showing 8 changed files with 282 additions and 10 deletions.
42 changes: 42 additions & 0 deletions __unconfig_vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
let __unconfig_data
const __unconfig_stub = function (data) {
__unconfig_data = data
}
__unconfig_stub.default = (data) => {
__unconfig_data = data
}
import * as path from 'path'
import dts from 'vite-plugin-dts'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import libCss from 'vite-plugin-libcss'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { terser } from 'rollup-plugin-terser'

// https://vitejs.dev/config/
const __unconfig_default = defineConfig({
base: './',
plugins: [vue(), vueJsx(), dts(), libCss()],
build: {
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: 'SimpleWorkerTimer',
fileName: (format) => `index.${format}.js`
},
// https://rollupjs.org/guide/en/#big-list-of-options
rollupOptions: {
treeshake: true,
external: ['vue'],
output: {
globals: {
vue: 'vue'
},
exports: 'named'
},
plugins: [terser({ compress: { drop_console: true } })]
}
}
})

if (typeof __unconfig_default === 'function') __unconfig_default(...[{ command: 'serve', mode: 'development' }])
export default __unconfig_data
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple-worker-timer",
"version": "1.0.0",
"version": "1.0.2",
"sideEffects": false,
"description": "一个基于web worker的翻牌计时器",
"keywords": [
Expand Down Expand Up @@ -69,6 +69,8 @@
"rollup-plugin-terser": "^7.0.2",
"typescript": "^4.6.4",
"vite": "^3.0.7",
"vite-plugin-dts": "^1.4.1",
"vite-plugin-libcss": "^1.0.5",
"vue-tsc": "^0.39.5",
"web-norm": "^1.0.24"
},
Expand Down
Loading

0 comments on commit 6926168

Please sign in to comment.