Skip to content

Commit

Permalink
feature: 添加构建命令
Browse files Browse the repository at this point in the history
  • Loading branch information
jsxiaosi committed Oct 24, 2021
1 parent f1efb1c commit 805e472
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions build/vite/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ export function createViteBuild(): BuildOptions {
// 启用/禁用 CSS 代码拆分。当启用时,在异步 chunk 中导入的 CSS 将内联到异步 chunk 本身,并在块加载时插入 如果禁用,整个项目中的所有 CSS 将被提取到一个 CSS 文件中。
cssCodeSplit: false,
// 构建后是否生成 source map 文件。
sourcemap: true,
sourcemap: false,
// 启用/禁用 brotli 压缩大小报告。压缩大型输出文件可能会很慢,因此禁用该功能可能会提高大型项目的构建性能。
brotliSize: true,
// chunk 大小警告的限制(以 kbs 为单位)
chunkSizeWarningLimit: 500,
chunkSizeWarningLimit: 2000,
}
return viteBuild
}
9 changes: 7 additions & 2 deletions build/vite/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@ export function createViteResolve(
mode: string,
myDirname: string
): myResolveOptions {
// 解决警告You are running the esm-bundler build of vue-i18n. It is recommended to configure your bundler to explicitly replace feature flag globals with boolean literals to get proper tree-shaking in the final bundle.
const I18nAlias: AliasOptions =
mode === 'development'
? { 'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js' }
: {}
const viteResolve: myResolveOptions = {
// 引用别名配置
alias: {
// 配置@别名
'@': `${path.resolve(myDirname, 'src')}`,
// 配置#别名
'#': `${path.resolve(myDirname, 'types')}`,
// 解决警告You are running the esm-bundler build of vue-i18n. It is recommended to configure your bundler to explicitly replace feature flag globals with boolean literals to get proper tree-shaking in the final bundle.
'vue-i18n': mode === 'development' ? 'vue-i18n/dist/vue-i18n.cjs.js' : '',
...I18nAlias,
},
// 导入时想要省略的扩展名列表。注意,不 建议忽略自定义导入类型的扩展名(例如:.vue),因为它会干扰 IDE 和类型支持。
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json'],
}

return viteResolve
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"lint:lint-staged": "lint-staged -c ./.husky/lintstagedrc.js",
"lint:pretty": "pretty-quick --staged",
"lint:staged": "lint-staged",
"prepare": "husky install"
"prepare": "husky install",
"push": "scp -r dist/* root@服务器公网IP:/服务器资源存放地址",
"build:push": "npm run build && npm run push"
},
"dependencies": {
"element-plus": "^1.1.0-beta.12",
Expand Down

0 comments on commit 805e472

Please sign in to comment.