The problem that referencing js in webpack will package all js of the same level directory

< H2 > problem description < / H2 >

this is the weex project. Weex does not support writing local images directly in src. So I converted all the images to base64 values and then referenced the base64 to achieve the same effect. However, there is a problem. localPic is a module method to read the Base64 value of the image. The packaged page will contain all the js code under the images folder.

if I write the path of the file in the localPic method, I won"t have this problem, and all the js files in the same directory will be packaged with the variable .

< H2 > expect results < / H2 >

I can pack whatever js I want to quote. do not pack all of them . How can I solve this problem?

< hr >

Picture js: with Base64 value

base64js

js:
js

:


of course it does. If you want the result of return require , then require belongs to Synchronize, so you can't request pictures remotely.
if you want to require asynchronously, you need to do code splitting, documentation and see here ides/code-splitting/" rel=" nofollow noreferrer "> https://webpack.docschina.org.


can't find a better way, and there is no answer to the popularity of the forum. Finally, let's make a transition in the following way:

import someImage from '../../libs/images/back_white@2x.png.js'
data () {
    return {
      icons: someImage
    }
}
<image :src="icons.someImage"></image>
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b32cba-2be4c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b32cba-2be4c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?