user3531149
user3531149

Reputation: 1539

How to change the request path in webpack

Im trying to integrate PhotoSwipe into my current Project

this is the 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
};

this is my main file

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

enter image description here

for some reason its trying to find the compiled file from the project root like

'/1.output.js'

I need it to try to fetch the output file from

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

instead, how can I do that?

Upvotes: 0

Views: 310

Answers (1)

Faouzi Oudouh
Faouzi Oudouh

Reputation: 820

Add publicPath to your output object :

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

Upvotes: 2

Related Questions