assign-layer-names.js 466 B

1234567891011121314151617
  1. "use strict"
  2. module.exports = function (layer, node, state, options) {
  3. layer.forEach((layerPart, i) => {
  4. if (layerPart.trim() === "") {
  5. if (options.nameLayer) {
  6. layer[i] = options
  7. .nameLayer(state.anonymousLayerCounter++, state.rootFilename)
  8. .toString()
  9. } else {
  10. throw node.error(
  11. `When using anonymous layers in @import you must also set the "nameLayer" plugin option`
  12. )
  13. }
  14. }
  15. })
  16. }