mrsum / webpack-svgstore-plugin

Simple svg-sprite creating with webpack
https://www.npmjs.com/package/webpack-svgstore-plugin
200 stars 92 forks source link

Using variable in 'name' causes errors #151

Closed ben-styling closed 6 years ago

ben-styling commented 6 years ago

Code as per example

const __svg__ = {
  path: '../images/icons/*.svg',
  name: '../assets/images/svg-sprite/[hash].icons.svg'
}

I'd like to do this

const __svg__ = {
  path: '../images/icons/*.svg',
  name: '../assets/images/svg-sprite/' + __webpack_hash__ + '.icons.svg'
  //or this: name: `../assets/images/svg-sprite/${ __webpack_hash__}.icons.svg`
}

However I'm getting this error:

Module parse failed: ...\node_modules\babel-loader\lib\index.js??ref--1!...\node_modules\jshint-loader\index.js??ref--0...\assets\js\main.js Cannot read property 'indexOf' of undefine d ^This error message seems like it might be unrelated to this plugin? But it works fine if I use a static name or user [hash]

The reason I want this is to insert the svg into the document via php (using stats.json) to prevent the displayed delay of waiting for js to insert it.

If I'm going about this problem all wrong please let me know!

sectsect commented 6 years ago

I have same problem.

lgordey commented 6 years ago

@GoldenRust You should use exactly [hash] like a string, it will be replaced with actual hash on build stage. cc: @sectsect