Answer the question
In order to leave comments, you need to log in
How to pass webpack media variable to script?
Good afternoon.
How to pass a variable to the script itself? I do it through DefinePlugin, but as a result I get undefined. Thanks in advance for your reply!
const Elixir = require('laravel-elixir');
const webpack = require('webpack');
require('laravel-elixir-webpack-official');
require('laravel-elixir-vue-2');
Elixir.webpack.config.plugins = [
new webpack.DefinePlugin({
'process.env': {
'API_URL': JSON.stringify("http://domain.com/api_url")
}
})
];
Elixir(
mix => {
mix.webpack('./src/app.js', publicPath),
mix.copy(nodeModulesPath+"/font-awesome/fonts/",publicPath+"/fonts/")
}
);
mounted(){
console.log(process.env.API_URL); // undefined
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question