gpt4 book ai didi

javascript - 如何更改webpack中的请求路径

转载 作者:行者123 更新时间:2023-12-02 13:50:18 24 4
gpt4 key购买 nike

我正在尝试集成 PhotoSwipe进入我当前的项目

这是 webpack.config.js

module.exports =
{
entry: './input.js',
output:
{
path: 'js/',
filename: 'output.js'
},
resolve:
{
alias:
{
'photoswipe_js': './node_modules/photoswipe/dist/photoswipe.js',
'photoswipe_ui_default': './node_modules/photoswipe/dist/photoswipe-ui-default.js'
}
},
watch: true
};

这是我的主文件

require(['photoswipe_js', 'photoswipe_ui_default'], function( PhotoSwipe, PhotoSwipeUI_Default )
{
console.log(PhotoSwipe);
console.log(PhotoSwipeUI_Default);
});

enter image description here

出于某种原因,它试图从项目根目录中查找编译后的文件喜欢

'/1.output.js'

我需要它来尝试从中获取输出文件

'/bundles/mybundle/js/1.output.js'

相反,我该怎么做?

最佳答案

publicPath 添加到您的输出对象:

module.exports =
{
...
output:
{
path: 'js/',
filename: 'output.js',
publicPath: '/bundles/mybundle/js/'
},
...
};

关于javascript - 如何更改webpack中的请求路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41038010/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com