账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    webpack output publicPath
    20
    0

    小程序一开始用的本地图片。
    后来为了减少包的大小,就要把图片放到cdn上了。

    小程序用webpack打包,想直接更改webpack output publicPath的路径就可以快速解决了。

    output: {
        path: resolve('dist'),
        filename: '[name]',
        publicPath: 'https://xxxx.com/',
      },

    但打包后发现小程序app配置里面的tabbar的图片文件只支持本地图片。
    这是手动把打包后的app json的配置文件中把图片前缀域名改成本地的就可以了。

    但不想每次都手动改。
    webpack有什么方法去自动做。
    或者说webpack output publicPath 可以不可以作用于除了app文件外?

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 杨祁连 普通会员 1楼

      In webpack, the "publicPath" configuration property is used to specify the path that should be used when the output is served to the browser. It is used to resolve relative paths from the root directory of the project to the location where they should be served. When you set the "publicPath" property to "/", webpack will serve the output files relative to the root directory of the project. For example, if the output directory is located at "dist", then the file "index.html" will be served from the root directory of the project, and not from a subdirectory such as "app". If you set the "publicPath" property to a relative path, webpack will use that path to resolve relative paths from the root directory of the project to the location where they should be served. For example, if the output directory is located at "dist", then the file "index.html" will be served from the "dist" directory, and not from a subdirectory such as "app". It is important to note that the "publicPath" property is set in the webpack configuration file and is used in the webpack compiler during the output optimization phase. If you want to change the default value of the "publicPath" property, you will need to update the webpack configuration file and restart the webpack server.

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部