From bf01881c97cce4ea5b78b9966db9f21910ee2fe2 Mon Sep 17 00:00:00 2001 From: HJM515 <49134737+HJM515@users.noreply.github.com> Date: Sun, 7 May 2023 17:36:25 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20add=20vue-cli5=20solutions=20of?= =?UTF-8?q?=20"After=20the=20micro-app=20is=20bundled,=20the=20font=20file?= =?UTF-8?q?s=20and=20images=20in=20the=20css=20load=20404"=20(#2485)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/faq/README.md | 11 +++++++++++ docs/faq/README.zh.md | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/docs/faq/README.md b/docs/faq/README.md index 0d87a45..56cdfb4 100644 --- a/docs/faq/README.md +++ b/docs/faq/README.md @@ -320,6 +320,17 @@ module.exports = { }; ``` +`vue-cli5` project, use the `asset/inline` of `webpack` replace `url-loader`: + +```js +module.exports = { + chainWebpack: (config) => { + config.module.rule('fonts').type('asset/inline').set('generator', {}); + config.module.rule('images').type('asset/inline').set('generator', {}); + }, +}; +``` + 3. Use the `file-loader` of `webpack` to inject the full path when packaging it (suitable for projects with large font files and images) ```js diff --git a/docs/faq/README.zh.md b/docs/faq/README.zh.md index ec1e666..8dbb26c 100644 --- a/docs/faq/README.zh.md +++ b/docs/faq/README.zh.md @@ -322,6 +322,17 @@ module.exports = { }; ``` +`vue-cli5` 项目,使用 `asset/inline` 替代 `url-loader`,写法: + +```js +module.exports = { + chainWebpack: (config) => { + config.module.rule('fonts').type('asset/inline').set('generator', {}); + config.module.rule('images').type('asset/inline').set('generator', {}); + }, +}; +``` + 3. 借助 `webpack` 的 `file-loader` ,在打包时给其注入完整路径(适用于字体文件和图片体积比较大的项目) ```js