feat: 对齐 webpack 和 vite 文件输出

This commit is contained in:
winixt 2023-03-31 18:19:35 +08:00
parent ee2e79c004
commit 852aad294c
12 changed files with 4328 additions and 3158 deletions

View File

@ -1,22 +0,0 @@
#!/usr/bin/env sh
# 确保脚本抛出遇到的错误
set -e
# 生成静态文件
npm run build
# 进入生成的文件夹
cd docs/.vuepress/dist
# 如果是发布到自定义域名
# echo 'www.example.com' > CNAME
git init
git add -A
git commit -m 'deploy'
# 如果发布到 https://<USERNAME>.github.io/<REPO>
git push -f https://github.com/WeBankFinTech/fes.js.git master:gh-pages
cd -

View File

@ -9,10 +9,10 @@
],
"scripts": {
"bootstrap": "pnpm i",
"clean": "rm -rf packages/**/node_modules & rm -rf node_modules",
"dev": "node scripts/build.mjs --watch",
"build": "node scripts/build.mjs",
"release": "node scripts/release.mjs",
"clean": "rm pnpm-lock.yaml & rm -rf node_modules & rm -rf packages/**/node_modules & rm -rf packages/**/.cache",
"docs:dev": "vuepress dev docs --clean-cache",
"docs:build": "vuepress build docs --clean-cache",
"test": "fes test",

View File

@ -46,6 +46,7 @@ export default async (api) => {
terserOptions: build.terserOptions || api.config.terserOptions,
target: build.target || getEsbuildTarget(targets),
outDir: build.outDir || api.config.outputPath || 'dist',
assetsDir: build.assetsDir || 'static',
assetsInlineLimit: build.assetsInlineLimit || api.config.inlineLimit || 8192,
},
});

View File

@ -93,8 +93,8 @@ export default function createCssWebpackConfig({ isDev, config, webpackConfig, b
if (!isDev) {
webpackConfig.plugin('extra-css').use(require.resolve('mini-css-extract-plugin'), [
{
filename: '[name].[contenthash:8].css',
chunkFilename: '[id].[contenthash:8].css',
filename: 'static/[name].[contenthash:8].css',
chunkFilename: 'static/[id].[contenthash:8].css',
},
]);
webpackConfig.optimization.minimizer('css').use(require.resolve('css-minimizer-webpack-plugin'), [{}]);

View File

@ -77,8 +77,8 @@ export default async function getConfig({ api, cwd, config, env, entry = {}, mod
webpackConfig.output
.path(absoluteOutput)
.publicPath(publicPath || '/')
.filename('[name].[contenthash:8].js')
.chunkFilename('[name].[contenthash:8].chunk.js');
.filename('static/[name].[contenthash:8].js')
.chunkFilename('static/[name].[contenthash:8].chunk.js');
// --------------- resolve -----------
webpackConfig.resolve.extensions.merge(['.mjs', '.js', '.jsx', '.vue', '.ts', '.tsx', '.json', '.wasm']);

View File

@ -28,7 +28,7 @@
"dependencies": {
"@swc/core": "^1.3.37",
"@swc/css": "^0.0.20",
"swc-plugin-vue-jsx": "^0.2.0",
"swc-plugin-vue-jsx": "^0.2.1",
"swc-loader": "^0.2.3",
"@fesjs/utils": "^3.0.0-rc.2",
"terser-webpack-plugin": "^5.3.6",
@ -37,4 +37,4 @@
"peerDependencies": {
"@fesjs/fes": "^3.0.0-rc.0"
}
}
}

View File

@ -1,5 +1,6 @@
html {
body {
margin: 0px;
font-size: 16px;
}
}

View File

@ -2,11 +2,7 @@ import { defineBuildConfig } from '@fesjs/fes';
export default defineBuildConfig({
swc: {
loader: {
env: {
coreJs: '3.27',
},
},
loader: {},
},
targets: {
chrome: '78',

File diff suppressed because it is too large Load Diff

View File

@ -44,11 +44,15 @@ const arrToObj = (arr, key) =>
async function publishPackage(pkg, runIfNotDry) {
step(`Publishing ${pkg.name}...`);
try {
let _releaseTag;
if (pkg.newVersion.includes('-')) {
_releaseTag = 'next';
}
await runIfNotDry(
// note: use of pnpm is intentional here as we rely on its publishing
// behavior.
'npm',
['publish', '--access', 'public', '--registry', 'https://registry.npmjs.org'],
['publish', ...(_releaseTag ? ['--tag', _releaseTag] : []), '--access', 'public', '--registry', 'https://registry.npmjs.org'],
{
cwd: getPkgRoot(pkg.dirName),
stdio: 'pipe',
@ -94,13 +98,13 @@ function updatePackage(pkgName, version, pkgs) {
pkgJson.dependencies &&
Object.keys(pkgJson.dependencies).forEach((npmName) => {
if (pkgs[npmName]) {
pkgJson.dependencies[npmName] = pkgs[npmName].newVersion;
pkgJson.dependencies[npmName] = `^${pkgs[npmName].newVersion}`;
}
});
pkgJson.peerDependencies &&
Object.keys(pkgJson.peerDependencies).forEach((npmName) => {
if (pkgs[npmName]) {
pkgJson.peerDependencies[npmName] = pkgs[npmName].newVersion;
pkgJson.peerDependencies[npmName] = `^${pkgs[npmName].newVersion}`;
}
});
writePackageJson(pkgName, pkgJson);

View File

@ -3,7 +3,7 @@
"composite": true,
"declaration": true,
"declarationMap": true,
"lib": ["DOM", "ES2020"],
"lib": ["DOM", "ESNext"],
"module": "CommonJS",
"moduleResolution": "node",
"newLine": "lf",
@ -14,6 +14,6 @@
"sourceMap": true,
"strict": true,
"strictNullChecks": true,
"target": "ES2018"
"target": "ESNext"
}
}