From 55c8cf7e70377ca9fe42526e96562c6f06f94f67 Mon Sep 17 00:00:00 2001 From: Alexey Litvinov Date: Mon, 26 Oct 2015 23:50:09 +0300 Subject: [PATCH] magic replace --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 1f2bfe9..5c62ea3 100644 --- a/index.js +++ b/index.js @@ -39,6 +39,8 @@ module.exports = function createGenerator(pattern, options) { }; var genericName = interpolateName(loaderContext, name, loaderOptions); - return genericName; + return genericName + .replace(new RegExp('[^a-zA-Z0-9\\-_\u00A0-\uFFFF]', 'g'), '-') + .replace(/^([^a-zA-Z_])/, '_$1'); }; };