Webpack not loading partial files from the same ro

2019-09-11 02:08发布

I am compiling a javascript bundle with Webpack. I am specifiying a single file in my build task:

webpack({
    entry: 'src/js/main.js',
    output: { path: 'dist/js' }
}, function(e) {});

And then I am specifying some async packages in my bundle

require([ 'test.json' ], function() {});

Both the main bundle and the partial bundles compile into "dist/js/main.js", "dist/js/1.main.js", etc.

The main bundle loads from "localhost:8000/dist/js/main.js," but the async/partial dependencies are trying to load from "localhost:8000/1.main.js". Am I missing a critical piece of this?

1条回答
家丑人穷心不美
2楼-- · 2019-09-11 02:35

You need to set the publicPath property, eg:

{
    entry: 'src/js/main.js',
    output: {
        path: 'dist/js',
        publicPath: '/dist/js/'
    }
}

References:

查看更多
登录 后发表回答