Closed iamrane closed 7 years ago
@iamrane think that const
isn't parsed cause when plugin was wrote, let/const
not support
i mean use var
instead const
I changed to var. Still not working. Its just stops at "90% optimize assets" when i start webpack. If i hard code the value of a variable and try to use it, it still doesn't work. I guess its somehow how the svg magic is being used.
var __svg__ = { path: '../../../styles/mybrand/images/svg-icons/**/*.svg', name: '[hash].icons.svg' };
require('webpack-svgstore-plugin/src/helpers/svgxhr')(__svg__);
works fine but not
var brand = 'mybrand';
var __svg__ = { path: '../../../styles/' + brand + '/images/svg-icons/**/*.svg', name: '[hash].icons.svg' };
require('webpack-svgstore-plugin/src/helpers/svgxhr')(__svg__);
I made it work.
if (process.env.BRAND === 'mybrand') {
var __svg__ = { path: '../../../styles/mybrand/images/svg-icons/**/*.svg', name: '[hash].icons.svg' };
}
if (process.env.BRAND === 'myotherbrand') {
var __svg__ = { path: '../../../styles/myotherbrand/images/svg-icons/**/*.svg', name: '[hash].icons.svg' };
}
require('webpack-svgstore-plugin/src/helpers/svgxhr')(__svg__);
Hi! It seems to be something wrong when i use environment variables in my path value. I guess its the order that webpack do things.
From my understanding webpack replaces the env. variable on build, but it seems to me that svg magick is happening before this?
My code looks like
and plugins in config