JeffreyWay / laravel-elixir-webpack-official

88 stars 28 forks source link

How to set webpack publicPath #12

Closed tripper54 closed 8 years ago

tripper54 commented 8 years ago

Webpack is compiling the images in my Vue components OK, and saving them to public/js .

But the image path printed doesn't include the js/ prefix, it's just the compiled filename. So the output in the browser shows a broken image.

How do I set the webpack publicPath property to fix this?

I have tried

Elixir.webpack.mergeConfig({
    module: {
        output: {
            publicPath: 'js/',
        },
        loaders: [
            {
                test: /\.svg$/,
                loader: 'file',
            },
        ],
    }
});

But it seems the value for publicPath is being ignored.

grusch-it commented 8 years ago

Try to add __webpack_public_path__ = '/js/' on top of resources/assets/js/app.js:

// app.js

__webpack_public_path__ = '/js/'

// ...

require('./bootstrap')

// ...
srph commented 8 years ago

It shouldn't be under the module object.

Elixir.webpack.mergeConfig({
+  output: {
+      publicPath: 'js/',
+  },
    module: {
-        output: {
-            publicPath: 'js/',
-        },
        loaders: [
            {
                test: /\.svg$/,
                loader: 'file',
            },
        ],
    }
});
tripper54 commented 8 years ago

thanks, my bad!