@dcasia/mini-program-tailwind-webpack-plugin
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -31,12 +31,18 @@ 'use strict'; | ||
var _a; | ||
var FileType; | ||
(function (FileType) { | ||
FileType[FileType["Template"] = 0] = "Template"; | ||
FileType[FileType["Style"] = 1] = "Style"; | ||
})(FileType || (FileType = {})); | ||
var _a, _b; | ||
function isStyleFile(filename) { | ||
return function (filename) { return /.+\.(?:wx|ac|jx|tt|q|c)ss$/.test(filename); }; | ||
return /.+\.(?:wx|ac|jx|tt|q|c)ss$/.test(filename); | ||
} | ||
function isTemplateFile(filename) { | ||
return function (filename) { return /.+\.(wx|ax|jx|ks|tt|q)ml$/.test(filename); }; | ||
return /.+\.(wx|ax|jx|ks|tt|q)ml$/.test(filename); | ||
} | ||
var specialCharactersMap = (_a = {}, | ||
_a['['] = '_l_', | ||
_a['\\'] = '_b_', | ||
_a[']'] = '_r_', | ||
_a['('] = '_p_', | ||
@@ -48,8 +54,13 @@ _a[')'] = '_q_', | ||
_a['.'] = '_d_', | ||
_a['\\w:\\w'] = '_c_', | ||
// eslint-disable-next-line no-useless-escape | ||
_a['\w:\\w'] = '_c_', | ||
_a); | ||
function handleCharacters(content) { | ||
var backslasheMap = (_b = {}, | ||
_b[FileType.Style] = '\\\\\\', | ||
_b[FileType.Template] = '\\', | ||
_b); | ||
function handleCharacters(content, type) { | ||
for (var from in specialCharactersMap) { | ||
var to = specialCharactersMap[from]; | ||
var regExp = new RegExp("\\".concat(from), 'g'); | ||
var regExp = new RegExp(backslasheMap[type] + from, 'g'); | ||
/** | ||
@@ -70,3 +81,3 @@ * Todo | ||
if (node.type === 'rule') { | ||
node.selector = handleCharacters(node.selector); | ||
node.selector = handleCharacters(node.selector, FileType.Style); | ||
} | ||
@@ -88,3 +99,3 @@ }); | ||
if (node.attributes["class"]) { | ||
node.attributes["class"] = handleCharacters(node.attributes["class"]); | ||
node.attributes["class"] = handleCharacters(node.attributes["class"], FileType.Template); | ||
} | ||
@@ -116,10 +127,12 @@ } | ||
var handledSource = ''; | ||
if (isStyleFile()) { | ||
if (isStyleFile(pathname)) { | ||
handledSource = handleStyle(rawSource); | ||
} | ||
else if (isTemplateFile()) { | ||
else if (isTemplateFile(pathname)) { | ||
handledSource = hanldeTemplate(rawSource); | ||
} | ||
var source = new ConcatSource(handledSource); | ||
compilation.updateAsset(pathname, source); | ||
if (handledSource) { | ||
var source = new ConcatSource(handledSource); | ||
compilation.updateAsset(pathname, source); | ||
} | ||
} | ||
@@ -126,0 +139,0 @@ }); |
{ | ||
"name": "@dcasia/mini-program-tailwind-webpack-plugin", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6541
130