Skip to content

Commit

Permalink
feat: 升级 vite5
Browse files Browse the repository at this point in the history
  • Loading branch information
winixt committed Nov 29, 2023
1 parent fb54913 commit fdd3537
Show file tree
Hide file tree
Showing 27 changed files with 3,471 additions and 1,184 deletions.
22 changes: 0 additions & 22 deletions .eslintrc.js

This file was deleted.

2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
.DS_Store
.idea
.git
.vscode
.history
.cache
.temp
Expand Down
4 changes: 0 additions & 4 deletions .prettierrc.js

This file was deleted.

48 changes: 48 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
// Enable the ESlint flat config support
"eslint.experimental.useFlatConfig": true,

// Disable the default formatter, use eslint instead
"prettier.enable": false,
"editor.formatOnSave": false,

// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},

// Silent the stylistic rules in you IDE, but still auto fix them
"eslint.rules.customizations": [
{ "rule": "style/*", "severity": "off" },
{ "rule": "*-indent", "severity": "off" },
{ "rule": "*-spacing", "severity": "off" },
{ "rule": "*-spaces", "severity": "off" },
{ "rule": "*-order", "severity": "off" },
{ "rule": "*-dangle", "severity": "off" },
{ "rule": "*-newline", "severity": "off" },
{ "rule": "*quotes", "severity": "off" },
{ "rule": "*semi", "severity": "off" }
],

// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml"
],

"pair-diff.patterns": [
{
"source": "./fixtures/output/**/*.*",
"target": "./fixtures/input/<base>"
}
]
}
2 changes: 1 addition & 1 deletion build.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
pkgs: [
'create-fes-app',
'fes',
Expand Down
20 changes: 20 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// eslint.config.js
import antfu from '@antfu/eslint-config';

export default await antfu({
stylistic: {
indent: 4, // 4, or 'tab'
quotes: 'single', // or 'double'
semi: 'always',
},
typescript: true,
vue: true,
rules: {
'vue/block-order': [
'error',
{
order: ['template', 'script', 'style'],
},
],
},
});
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"workspaces": [
"packages/*"
],
"type": "module",
"scripts": {
"bootstrap": "pnpm i",
"dev": "node scripts/build.mjs --watch",
Expand Down Expand Up @@ -37,16 +38,17 @@
"semver": "^7.3.6"
},
"devDependencies": {
"@antfu/eslint-config": "^2.1.1",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@webank/eslint-config-webank": "1.2.7",
"chokidar": "^3.5.3",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"deepmerge": "^4.2.2",
"eslint": "^8.54.0",
"fs-extra": "^11.1.1",
"husky": "^8.0.3",
"lint-staged": "^13.2.0",
"simple-git-hooks": "^2.9.0",
"typescript": "^5.0.4",
"vitepress": "1.0.0-alpha.73",
"vue": "^3.3.4",
Expand All @@ -57,11 +59,9 @@
"npm run lint"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
"simple-git-hooks": {
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
},
"config": {
"commitizen": {
Expand Down
115 changes: 57 additions & 58 deletions packages/fes-builder-vite/package.json
Original file line number Diff line number Diff line change
@@ -1,60 +1,59 @@
{
"name": "@fesjs/builder-vite",
"version": "3.0.4",
"description": "@fesjs/builder-vite",
"main": "lib/index.js",
"files": [
"lib",
"types.d.ts"
],
"repository": {
"type": "git",
"url": "git+https://github.com/WeBankFinTech/fes.js.git",
"directory": "packages/fes-builder-vite"
},
"keywords": [
"fes"
],
"author": "qlin",
"license": "MIT",
"bugs": {
"url": "https://github.com/WeBankFinTech/fes.js/issues"
},
"homepage": "https://github.com/WeBankFinTech/fes.js#readme",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@babel/core": "^7.21.3",
"@fesjs/utils": "^3.0.1",
"@vitejs/plugin-basic-ssl": "^1.0.1",
"@vitejs/plugin-legacy": "^3.0.1",
"@vitejs/plugin-vue": "^4.0.0",
"@vitejs/plugin-vue-jsx": "^3.0.0",
"autoprefixer": "^10.4.4",
"babel-plugin-polyfill-corejs3": "^0.7.1",
"less": "^4.1.2",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-safe-parser": "^6.0.0",
"rollup-plugin-visualizer": "^5.6.0",
"terser": "^5.16.8",
"vite": "^4.2.1",
"@rollup/pluginutils": "^4.2.0",
"colorette": "^2.0.16",
"connect-history-api-fallback": "^2.0.0",
"consola": "^2.15.3",
"dotenv": "^16.0.0",
"dotenv-expand": "^8.0.2",
"ejs": "^3.1.6",
"fast-glob": "^3.2.11",
"fs-extra": "^10.0.1",
"html-minifier-terser": "^6.1.0",
"node-html-parser": "^5.3.3",
"pathe": "^0.2.0"
},
"peerDependencies": {
"@fesjs/fes": "^3.1.4",
"core-js": "^3.29.1"
},
"typings": "./types.d.ts"
"name": "@fesjs/builder-vite",
"version": "3.0.4",
"description": "@fesjs/builder-vite",
"author": "qlin",
"license": "MIT",
"homepage": "https://github.com/WeBankFinTech/fes.js#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/WeBankFinTech/fes.js.git",
"directory": "packages/fes-builder-vite"
},
"bugs": {
"url": "https://github.com/WeBankFinTech/fes.js/issues"
},
"keywords": [
"fes"
],
"main": "lib/index.js",
"files": [
"lib",
"types.d.ts"
],
"publishConfig": {
"access": "public"
},
"peerDependencies": {
"@fesjs/fes": "^3.1.4",
"core-js": "^3.29.1"
},
"dependencies": {
"@babel/core": "^7.23.3",
"@fesjs/utils": "^3.0.1",
"@rollup/pluginutils": "^5.1.0",
"@vitejs/plugin-basic-ssl": "^1.0.2",
"@vitejs/plugin-legacy": "^5.2.0",
"@vitejs/plugin-vue": "^4.5.0",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"autoprefixer": "^10.4.4",
"colorette": "^2.0.16",
"connect-history-api-fallback": "^2.0.0",
"consola": "^2.15.3",
"dotenv": "^16.0.0",
"dotenv-expand": "^8.0.2",
"ejs": "^3.1.6",
"fast-glob": "^3.2.11",
"fs-extra": "^10.0.1",
"html-minifier-terser": "^6.1.0",
"less": "^4.2.0",
"node-html-parser": "^5.3.3",
"pathe": "^0.2.0",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-safe-parser": "^6.0.0",
"rollup-plugin-visualizer": "^5.9.3",
"terser": "^5.24.0",
"vite": "^5.0.3"
},
"typings": "./types.d.ts"
}
10 changes: 5 additions & 5 deletions packages/fes-builder-vite/src/common/getConfig.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { join } from 'path';
import { existsSync } from 'fs';
import { join } from 'node:path';
import { existsSync } from 'node:fs';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import { createHtmlPlugin } from './vite-plugin-html';
Expand All @@ -9,15 +9,15 @@ import getDefine from './getDefine';
function getPostcssConfig(api) {
// TODO 支持其他 postcss 配置文件类型
const configPath = `${api.paths.cwd}/postcss.config.js`;
if (existsSync(configPath)) {
if (existsSync(configPath))
return require(`${api.paths.cwd}/postcss.config.js`);
}

return {};
}

export function getInnerCommonConfig(api) {
const { deepmerge, resolveRuntimeEnv } = api.utils;
const { server, build, define, base, ...otherViteOption } = api.config.viteOption;
const { base, ...otherViteOption } = api.config.viteOption;

const publicPath = base || api.config.publicPath || '/';

Expand Down
8 changes: 6 additions & 2 deletions packages/fes-builder-vite/src/common/getDefine.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ export default (api, publicPath) => {
...api.config.define,
...viteOption.define,
});

const formatEnv = Object.keys(env).reduce((acc, cur) => {
acc[`process.env.${cur}`] = JSON.stringify(env[cur]);
return acc;
}, {});
console.log(formatEnv);
return {
'process.env': env,
...formatEnv,
...define,
};
};
Loading

0 comments on commit fdd3537

Please sign in to comment.