So in Laravel Mix it says in the docs we can add stuff to our .env file prefixed with MIX_ and we can then access it in our JS file when compiled.
I think I may be missi
@Ohgodwhy's answer works, but need slight modification for new mix version
require('dotenv').config()
let webpack = require('webpack')
let dotenvplugin = new webpack.DefinePlugin({
'process.env': {
APP_NAME: JSON.stringify(process.env.APP_NAME || 'Default app name'),
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
}
})
mix.webpackConfig({
...
plugins: [
dotenvplugin,
]