Skip to content

Commit

Permalink
fix: remove mpx url-loader config in build web mode (mpx-ecology#14)
Browse files Browse the repository at this point in the history
* style: mpx-mp index code style
  • Loading branch information
mater1996 authored Mar 24, 2022
1 parent f53e3cd commit c7a62b2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
21 changes: 21 additions & 0 deletions packages/vue-cli-plugin-mpx-mp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,27 @@ module.exports = function (api, options) {
const wxmlLoader = MpxWebpackPlugin.wxmlLoader()
const wxssLoader = MpxWebpackPlugin.wxssLoader()

let imgLoaderConfig = {
name: 'img/[name][hash].[ext]'
}
if (
options &&
options.pluginOptions &&
options.pluginOptions.mpx &&
options.pluginOptions.mpx.urlLoader
) {
imgLoaderConfig = options.pluginOptions.mpx.urlLoader
}
const mpxUrlLoader = MpxWebpackPlugin.urlLoader(imgLoaderConfig)

webpackConfig.module.rules.delete('images')
webpackConfig.module
.rule('images')
.test(/\.(png|jpe?g|gif|svg)$/)
.use('mpx-url-loader')
.loader(mpxUrlLoader.loader)
.options(mpxUrlLoader.options)

webpackConfig.module
.rule('mpx')
.test(/\.mpx$/)
Expand Down
20 changes: 0 additions & 20 deletions packages/vue-cli-plugin-mpx/config/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,6 @@ module.exports = function (api, options, webpackConfig) {
.use('mpx-wxs-pre-loader')
.loader(MpxWebpackPlugin.wxsPreLoader().loader)

webpackConfig.module.rules.delete('images')
let imgLoaderConfig = {
name: 'img/[name][hash].[ext]'
}
if (
options &&
options.pluginOptions &&
options.pluginOptions.mpx &&
options.pluginOptions.mpx.urlLoader
) {
imgLoaderConfig = options.pluginOptions.mpx.urlLoader
}
const mpxUrlLoader = MpxWebpackPlugin.urlLoader(imgLoaderConfig)
webpackConfig.module
.rule('images')
.test(/\.(png|jpe?g|gif|svg)$/)
.use('mpx-url-loader')
.loader(mpxUrlLoader.loader)
.options(mpxUrlLoader.options)

const transpileDepRegex = genTranspileDepRegex(options.transpileDependencies || [])
webpackConfig.module
.rule('js')
Expand Down

0 comments on commit c7a62b2

Please sign in to comment.