由于 domain 跨域,cookie 无法携带,后端无法通过 cookie 获取登录验证码。

可以从 npm run dev 中登录将浏览器缓存的 USER 拷贝到 http://localhost:4173 跳过登录,查看页面内容。

TS 检查报错

当前使用的 element-plus 版本是 v.2.1.8 ,打包时会报错:

node_modules/element-plus/es/components/time-select/index.d.ts:108:38 - error TS2304: Cannot find name 'ComponentSize'.
108         type: import("vue").PropType<ComponentSize>;
node_modules/element-plus/es/components/time-select/index.d.ts:277:38 - error TS2304: Cannot find name 'ComponentSize'.
277         type: import("vue").PropType<ComponentSize>;
node_modules/element-plus/lib/components/time-select/index.d.ts:108:38 - error TS2304: Cannot find name 'ComponentSize'.
108         type: import("vue").PropType<ComponentSize>;
node_modules/element-plus/lib/components/time-select/index.d.ts:277:38 - error TS2304: Cannot find name 'ComponentSize'.
277         type: import("vue").PropType<ComponentSize>;

这是因为 element-plus 的 time-select 组件类型声明文件中使用了 ts 类型 ComponentSize

// node_modules\element-plus\lib\components\time-select\index.d.ts
size: {
    type: import("vue").PropType<ComponentSize>;
    values: readonly ["", "default", "small", "large"];
    default: string;

而该文件中并没有 import 该类型,从源码中查看应该从此模块中引入:

import type { ComponentSize } from '@element-plus/constants'

类型定义:

// node_modules\element-plus\es\constants\size.d.ts
export declare const componentSizes: readonly ["", "default", "small", "large"];
export declare type ComponentSize = typeof componentSizes[number];
export declare const componentSizeMap: {
    readonly large: 40;
    readonly default: 32;
    readonly small: 24;
export declare const getComponentSize: (size?: ComponentSize) => 40 | 32 | 24;

当前只有 time-select 组件的类型声明文件使用了这个类型,而其他组件使用的并不是 ComponentSize,而是:

// 以 button 组件为例
// node_modules\element-plus\lib\components\button\index.d.ts
readonly size: import("element-plus/es/utils").BuildPropReturn<StringConstructor, never, false, "" | "default" | "small" | "large", never>;

解决办法:

究其原因就是打包的时候 TypeScript 对 .d.ts 类型声明文件进行了校验,可以通过配置 skipLibChecktrue,跳过声明文件的类型检查。

官方没有找到相关解决办法,我就自己提了个 Issue 有兴趣的可以跟踪看看:[Bug Report] [TypeScript] [time-select] Use the “vue-tsc” command to check ts and report an error: “Cannot find name ‘ComponentSize’. type: import(“vue”).PropType;”, without “{skipLibCheck: true}” in “tsconfig.ts” · Issue #7265 · element-plus/element-plus (github.com)

css 压缩警告

压缩 css 文件的时候报错:

rendering chunks (11)...warnings when minifying css:
▲ [WARNING] "@charset" must be the first rule in the file
    <stdin>:1:30461:
      1...;flex-wrap:wrap;font-size:0}@charset "UTF-8";.el-radio{--el-radi...

原因是 element-plus 的样式文件都包含 @charset "UTF-8"; 编码规则,规范要求 @charset 规则必须是样式表的第一个元素,前面不能有任何字符。

而打包结果将这些文件的内容合并,就存在 @charset "UTF-8"; 不在文件开头的情况。

解决办法:

postcss 可以获取样式表的规则,可以编写一个 postcss 插件@charset 规则移除。

配置 vite.config.ts

// vite.config.ts
export default defineConfig({
  css: {
    postcss: {
      plugins: [
        // 自定义 postcss 插件
          // 插件名称
          postcssPlugin: 'charset-removal',
          // 获取 @ 规则
          AtRule: {
            // 处理全部 @charset 规则
            charset: (atRule) => {
              // 移除规则
              atRule.remove()

推荐腾讯云的 Webify,它和 Vercel 很像。

  • 个人认为最大的好处就是支持 Gitee(Github 访问太难受了)
  • 国内网络
  • 将代码推动到 Git,自动触发应用构建和部署
  • 缺点:收费(可以按量计费,首个托管应用免费体验1个月)
  • 有关含羞草的更多信息,请参阅 。 将'minify-css'添加到您的模块列表中。 就这样! 当您启动mimosa watch或mimosa build时,Mimosa 将为您安装该模块。 当使用--optimize或--minify标志执行mimosa watch或mimosa build ,此模块将在写入输出之前缩小任何标识为.css文件。 这包括纯.css文件以及由任何 Mimosa CSS 编译器编译的任何文件。 minifyCSS: { exclude : [ / \. min \. / ] , options : { processImport : false vue3+vite+qiankun+monorepo框架vue3+vite+qiankun+monorepo框架vue3+vite+qiankun+monorepo框架vue3+vite+qiankun+monorepo框架vue3+vite+qiankun+monorepo框架vue3+vite+qiankun+monorepo框架vue3+vite+qiankun+monorepo框架vue3+vite+qiankun+monorepo框架vue3+vite+qiankun+monorepo框架vue3+vite+qiankun+monorepo框架vue3+vite+qiankun+monorepo框架vue3+vite+qiankun+monorepo框架vue3+vite+qiankun+monorepo框架vue3+vite+qiankun+monorepo框架vue3+vite+qiankun+monorepo框架vue3+vite+qiankun+monorepo框架vue3+vite+qiankun+monorepo框架 在控制台中记录PostCSS警告。 从PostCSS 4.1开始,单个PostCSS进程可以从其使用的所有插件中累积警告。 大概,插件作者希望您看到这些警告。 因此,该插件可以读取累积的警告(或仅来自您指定的插件的警告),对其进行格式化以方便阅读,并将其打印到控制台。 npm install postcss-log-warnings 将其添加到要记录其警告的所有插件之后的插件列表中,然后将其传递给options对象。 例如,使用 : gulp . task ( 'css' , function ( ) { return gulp . src ( './src/*.css' ) 上面这种报错是在从index.html引入CDN的情况下报错的。解决方式将package.json中的build部分改掉。解决方案,换用从vite.config.ts中引入CDN。解决方案:修改vite.config.ts文件配置。yarn dev 不报错,build就报错。css部分加上charset: false。改成这个样子就不再报错也可以正常打包了。vant采用cdn引入的方式报错。 vue3 vite 打包后报错warning: Expected identifier but found * warnings when minifying cssvite vue3如何解决warnings when minifying css: stdin> warning: Expected identifier but found * 报错,vue3 vite网站网页项目npm run build 打包后报错,vue3项目打包后出现黄色警告怎么消除,vue3 vite执行 build 打包后出现w 这里写自定义目录标题Vite 打包异常问题 (vite:css-post) renderChunk1、第一次打包尝试 vite 2.7.132、第二次打包尝试 vite 2.8.4 Vite 打包异常问题 (vite:css-post) renderChunk 1、第一次打包尝试 vite 2.7.13 抛出异常信息: PS E:\Project\outlier-frame-back\outlier-frame-back-admin> npm run build vite v2.7.13 buil 用pycharm导入BeautifulSoup时运行给出警告:warnings.warn( UserWarning: The soupsieve package is not installed. CSS selectors cannot be used.(已解决) 程序可以正常运行,但给出警告还是想解决 在搜索很多后无果,尝试过pip install soupsieve但显示已经安装。 解决方法: 最后在pycharm里的file->setting->python interpreter里点击 UglifyJS2 这个工具使用很长时间了,但之前都是在 gulp 自动构建 时用到了 UglifyJS 算法进行压缩. 最近玩了一下 UglifyJS2 ,做了一个 在线压缩javascript工具 欢迎点击玩耍. 为什么要压缩 javascript 因为每个人开发者的书写习惯,定义参数习惯,已经使用习惯都不一样. 所以相同的功能出自不同开发者代码各异.这里牵扯到一个代码所占...