aligajani
7 months ago
3792
47
Vapor

Why doesn't Laravel Vapor inject ASSET_URL in my build step?

Posted 7 months ago by aligajani

This is from my Github action below. You can see that ASSET_URL is empty.

> @ production /github/workspace/.vapor/build/app
> cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

ASSET URL IS: 
 DONE  Compiled successfully in 26754ms11:23:07 PM

This is my code in webpack.mix.js. The ASSET_URL is not being injected.

// To deal with Laravel Vapor
if (mix.inProduction()) {
    const ASSET_URL = process.env.ASSET_URL;
    console.log("ASSET URL IS: " + ASSET_URL);

    mix.webpackConfig(webpack => {
        return {
            plugins: [
                new webpack.DefinePlugin({
                    "process.env.ASSET_PATH": JSON.stringify(ASSET_URL)
                })
            ],
            output: {
                publicPath: ASSET_URL
            }
        };
    });

However, assets() and mix() helpers in blade on index.blade.php work just fine.

Please sign in or create an account to participate in this conversation.