From eeb9045acf374c582e91ac413aad820873309d94 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Mon, 25 Nov 2019 13:52:20 +0800 Subject: [PATCH] fix(v3): svg loader --- .../vue-cli-plugin-uni/lib/app-plus/index.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/vue-cli-plugin-uni/lib/app-plus/index.js b/packages/vue-cli-plugin-uni/lib/app-plus/index.js index 2d81fda2c..fb5bc4355 100644 --- a/packages/vue-cli-plugin-uni/lib/app-plus/index.js +++ b/packages/vue-cli-plugin-uni/lib/app-plus/index.js @@ -145,7 +145,16 @@ const v3 = { const isAppView = !!vueOptions.pluginOptions['uni-app-plus']['view'] // 处理静态资源 - const staticTypes = ['images', 'svg', 'media', 'fonts'] + webpackConfig.module + .rule('svg') + .use('file-loader') + .options({ + emitFile: isAppView, + outputPath (url, resourcePath, context) { + return path.relative(process.env.UNI_INPUT_DIR, resourcePath) + } + }) + const staticTypes = ['images', 'media', 'fonts'] staticTypes.forEach(staticType => { webpackConfig.module .rule(staticType) @@ -157,9 +166,9 @@ const v3 = { loader: 'file-loader', options: { emitFile: isAppView, - name: '[name].[ext]', - useRelativePath: true, - context: process.env.UNI_INPUT_DIR + outputPath (url, resourcePath, context) { + return path.relative(process.env.UNI_INPUT_DIR, resourcePath) + } } } })) -- GitLab