Skip to content

Commit

Permalink
build: migrate to vite bundler
Browse files Browse the repository at this point in the history
  • Loading branch information
ntnyq committed Feb 24, 2025
1 parent 48a721e commit 4472652
Show file tree
Hide file tree
Showing 8 changed files with 1,464 additions and 3,132 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"styl",
"tarojs",
"unplugin",
"vite",
"walleeeee",
"weapp",
"zhihu",
Expand Down
1 change: 1 addition & 0 deletions babel.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
[
'taro',
{
compiler: 'vite',
framework: 'vue3',
ts: true,
},
Expand Down
19 changes: 3 additions & 16 deletions config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@

import path from 'node:path'
import { defineConfig } from 'taro-define-config'
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin'

declare module 'taro-define-config' {
interface CustomPluginOptionsMap {
'taro-plugin-pinia': {}
}
}

/**
* resolve path
Expand All @@ -21,7 +14,7 @@ const resolve = (...args: string[]) => path.resolve(__dirname, '..', ...args)

export default defineConfig({
projectName: 'taro-vue3-zhihudaily',
date: '2022-5-21',
date: '2024-2-1',
designWidth: 750,
deviceRatio: {
640: 2.34 / 2,
Expand All @@ -31,9 +24,9 @@ export default defineConfig({
},
sourceRoot: 'src',
outputRoot: 'dist',
plugins: ['@tarojs/plugin-html', 'taro-plugin-pinia'],
plugins: ['@tarojs/plugin-html'],
compiler: {
type: 'webpack5',
type: 'vite',
prebundle: {
enable: false,
exclude: ['@nutui/nutui-taro', '@nutui/icons-vue-taro'],
Expand Down Expand Up @@ -80,9 +73,6 @@ export default defineConfig({
},
},
},
webpackChain(chain) {
chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin)
},
sassLoaderOption: {
sassOptions: {
silenceDeprecations: ['import'],
Expand All @@ -99,8 +89,5 @@ export default defineConfig({
config: {},
},
},
webpackChain(chain) {
chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin)
},
},
})
23 changes: 17 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
"@tarojs/plugin-platform-weapp": "catalog:",
"@tarojs/router": "catalog:",
"@tarojs/shared": "catalog:",
"@tarojs/webpack5-runner": "catalog:",
"@types/webpack-env": "^1.18.8",
"@tarojs/vite-runner": "catalog:",
"@vitejs/plugin-vue": "^5.2.1",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"@vue/babel-plugin-jsx": "^1.2.5",
"@vue/compiler-sfc": "^3.5.13",
"babel-preset-taro": "catalog:",
Expand All @@ -63,6 +64,7 @@
"tsconfig-paths-webpack-plugin": "^4.2.0",
"typescript": "^5.7.3",
"unplugin-vue-components": "^28.4.0",
"vite": "^4.5.9",
"vue-loader": "^17.4.2",
"vue-tsc": "^2.2.4",
"webpack": "^5.98.0"
Expand All @@ -71,8 +73,17 @@
"*.{js,ts,cjs,mjs,vue,yml,yaml,md,json}": "eslint --fix"
},
"browserslist": [
"last 3 versions",
"Android >= 4.1",
"ios >= 8"
]
"defaults and fully supports es6-module",
"maintained node versions"
],
"pnpm": {

Check failure on line 79 in package.json

View workflow job for this annotation

GitHub Actions / check

Expected object keys to be in specified order. 'pnpm' should be before 'nano-staged'
"onlyBuiltDependencies": [
"@parcel/watcher",
"@swc/core",
"@tarojs/binding",
"core-js",
"core-js-pure",
"esbuild"
]
}
}
4,544 changes: 1,437 additions & 3,107 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ catalog:
'@tarojs/runtime': ^4.0.9
'@tarojs/shared': ^4.0.9
'@tarojs/taro': ^4.0.9
'@tarojs/webpack5-runner': ^4.0.9
'@tarojs/vite-runner': ^4.0.9
babel-preset-taro: ^4.0.9
packages:
- .
4 changes: 3 additions & 1 deletion project.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"appid": "wx9d6b29dabbb43222",
"setting": {
"urlCheck": true,
"es6": true,
"es6": false,
"enhance": false,
"compileHotReLoad": false,
"postcss": false,
"minified": true
},
Expand Down
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title></title>
<script>
/* 以下为 H5 响应式脚本,请不要删除! */
/* 以下为 H5 响应式脚本,请不要删除!*/
/* prettier-ignore */
!function(x){function w(){var v,u,t,tes,s=x.document,r=s.documentElement,a=r.getBoundingClientRect().width;if(!v&&!u){var n=!!x.navigator.appVersion.match(/AppleWebKit.*Mobile.*/);v=x.devicePixelRatio;tes=x.devicePixelRatio;v=n?v:1,u=1/v}if(a>=640){r.style.fontSize="40px"}else{if(a<=320){r.style.fontSize="20px"}else{r.style.fontSize=a/320*20+"px"}}}x.addEventListener("resize",function(){w()});w()}(window);
</script>
Expand Down

0 comments on commit 4472652

Please sign in to comment.