question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

environment variables inside "webpack.mix.js" doesnt work anymore

See original GitHub issue
  • Laravel Mix Version: v1.4.2
  • Node Version v8.4.0
  • NPM Version v5.3.0
  • OS: OSX 10.11.6

Description:

using an evn variable no longer works on assets compilation, on older version of mix 0.11.4 it was working correctly.

Steps To Reproduce:

  • create a new folder and name it something like “resources/bulma/xxx.scss”
  • make an env var equal to that name “MIX_MM_FRAMEWORK=bulma”
  • compile against the env var name
mix.sass('resources/' + process.env.MIX_MM_FRAMEWORK + '/xxx.scss', 'public/assets/vendor/style.css')
    .version()

https://github.com/JeffreyWay/laravel-mix/issues/1096

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

78reactions
dabernathy89commented, Sep 1, 2017

@ctf0 BTW it looks like all you need to do is use the dotenv package yourself (already installed by Mix). For example, here’s how i’m using it to define the Browsersync proxy URL for a WordPress theme:

let mix = require('laravel-mix');
require('dotenv').config();
 
let proxy_url = process.env.BROWSERSYNC_PROXY_URL || 'local.wordpress.dev';

// .. your mix configuration here...
    .browserSync({
        proxy: proxy_url,
    });
5reactions
joseguscommented, Dec 17, 2018

I could i never realize that just using process.env.APP_URL works! I’m using laravel-mix v4, no need to require dotenv

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing in environment variables after upgrade to Laravel MIX 6
The problem is, that I cannot access the environment variable in webpack.mix.js anymore via process.env.ENV_FILE . Its value is undefined... I ...
Read more >
Mix environment variable in vanilla javascript - Laracasts
In webpack.mix.js I am using mix.scripts() to compile different JS files together. ... but when I use mix.js() my JS code doesn't work...
Read more >
MiniCssExtractPlugin - webpack
It creates a CSS file per JS file which contains CSS. It supports On-Demand-Loading of CSS and SourceMaps. It builds on top of...
Read more >
Moving A Laravel Webpack Project To Vite - TechvBlogs
Vite only supports ES modules, so require doesn't work anymore, and you need to import modules now in your scripts. Example - not...
Read more >
The Mix CLI | Laravel Mix Documentation
Compiling in a Local Environment. To build assets for development, reach for the npx mix command. Mix will then read your webpack.mix.js configuration...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found