breezify
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -41,2 +41,3 @@ "use strict"; | ||
const csso_1 = require("csso"); | ||
const escape_string_regexp_1 = __importDefault(require("escape-string-regexp")); | ||
const fs_1 = __importDefault(require("fs")); | ||
@@ -55,5 +56,4 @@ const class_map_js_1 = require("./class-map.js"); | ||
const tree = cssTree.parse(content); | ||
const ignoreClassPatterns = ((_a = cssOptions.ignoreClassPatterns) === null || _a === void 0 ? void 0 : _a.map((className) => new RegExp(className))) || | ||
[]; | ||
const includeClassPatterns = ((_b = cssOptions.includeClassPatterns) === null || _b === void 0 ? void 0 : _b.map((className) => new RegExp(className))) || []; | ||
const ignoreClassPatterns = ((_a = cssOptions.ignoreClassPatterns) === null || _a === void 0 ? void 0 : _a.map((className) => new RegExp((0, escape_string_regexp_1.default)(className)))) || []; | ||
const includeClassPatterns = ((_b = cssOptions.includeClassPatterns) === null || _b === void 0 ? void 0 : _b.map((className) => new RegExp((0, escape_string_regexp_1.default)(className)))) || []; | ||
function shouldInclude(className) { | ||
@@ -60,0 +60,0 @@ return includeClassPatterns.length |
@@ -41,2 +41,3 @@ "use strict"; | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const escape_string_regexp_1 = __importDefault(require("escape-string-regexp")); | ||
const fs = __importStar(require("fs")); | ||
@@ -82,3 +83,3 @@ const glob_1 = require("glob"); | ||
if (ignore.length && | ||
ignore.some((pattern) => new RegExp(pattern).test(filePath))) { | ||
ignore.some((pattern) => new RegExp((0, escape_string_regexp_1.default)(pattern)).test(filePath))) { | ||
return; | ||
@@ -85,0 +86,0 @@ } |
@@ -44,2 +44,3 @@ "use strict"; | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const escape_string_regexp_1 = __importDefault(require("escape-string-regexp")); | ||
const terser_1 = require("terser"); | ||
@@ -60,3 +61,3 @@ const css_functions_js_1 = require("./css-functions.js"); | ||
const { ignoreStringPatterns = [], skipRules = [], mode = "acorn", } = jsOptions; | ||
const ignoreRegExpPatterns = ignoreStringPatterns.map((pattern) => new RegExp(pattern, "m")); | ||
const ignoreRegExpPatterns = ignoreStringPatterns.map((pattern) => new RegExp((0, escape_string_regexp_1.default)(pattern), "m")); | ||
let newContent = ""; | ||
@@ -185,3 +186,3 @@ // Unescape classMap's keys | ||
for (const [key, value] of Object.entries(unescapedClassMap)) { | ||
const regex = new RegExp(`\\b${key}\\b`, "gm"); | ||
const regex = new RegExp(`\\b${(0, escape_string_regexp_1.default)(key)}\\b`, "gm"); | ||
newContent = newContent.replace(regex, value); | ||
@@ -188,0 +189,0 @@ } |
@@ -26,3 +26,3 @@ "use strict"; | ||
const booleanParser = (val) => val === "true"; | ||
program.version("1.1.2").name("breezify"); | ||
program.version("1.1.3").name("breezify"); | ||
program | ||
@@ -29,0 +29,0 @@ .command("do") |
import * as cssTree from "css-tree"; | ||
import { minify } from "csso"; | ||
import escapeStringRegexp from "escape-string-regexp"; | ||
import fs from "fs"; | ||
@@ -15,5 +16,4 @@ import { generateClassMap } from "./class-map.js"; | ||
const tree = cssTree.parse(content); | ||
const ignoreClassPatterns = cssOptions.ignoreClassPatterns?.map((className) => new RegExp(className)) || | ||
[]; | ||
const includeClassPatterns = cssOptions.includeClassPatterns?.map((className) => new RegExp(className)) || []; | ||
const ignoreClassPatterns = cssOptions.ignoreClassPatterns?.map((className) => new RegExp(escapeStringRegexp(className))) || []; | ||
const includeClassPatterns = cssOptions.includeClassPatterns?.map((className) => new RegExp(escapeStringRegexp(className))) || []; | ||
function shouldInclude(className) { | ||
@@ -20,0 +20,0 @@ return includeClassPatterns.length |
// Get a list of all files in the directory and subdirectories | ||
import chalk from "chalk"; | ||
import escapeStringRegexp from "escape-string-regexp"; | ||
import * as fs from "fs"; | ||
@@ -42,3 +43,3 @@ import { globSync } from "glob"; | ||
if (ignore.length && | ||
ignore.some((pattern) => new RegExp(pattern).test(filePath))) { | ||
ignore.some((pattern) => new RegExp(escapeStringRegexp(pattern)).test(filePath))) { | ||
return; | ||
@@ -45,0 +46,0 @@ } |
@@ -6,2 +6,3 @@ // Replace class names in JS content with care | ||
import chalk from "chalk"; | ||
import escapeStringRegexp from "escape-string-regexp"; | ||
import { minify } from "terser"; | ||
@@ -21,3 +22,3 @@ import { isSelectorString, replaceClassNamesInCSS } from "./css-functions.js"; | ||
const { ignoreStringPatterns = [], skipRules = [], mode = "acorn", } = jsOptions; | ||
const ignoreRegExpPatterns = ignoreStringPatterns.map((pattern) => new RegExp(pattern, "m")); | ||
const ignoreRegExpPatterns = ignoreStringPatterns.map((pattern) => new RegExp(escapeStringRegexp(pattern), "m")); | ||
let newContent = ""; | ||
@@ -149,3 +150,3 @@ // Unescape classMap's keys | ||
for (const [key, value] of Object.entries(unescapedClassMap)) { | ||
const regex = new RegExp(`\\b${key}\\b`, "gm"); | ||
const regex = new RegExp(`\\b${escapeStringRegexp(key)}\\b`, "gm"); | ||
newContent = newContent.replace(regex, value); | ||
@@ -152,0 +153,0 @@ } |
@@ -12,3 +12,3 @@ import chalk from "chalk"; | ||
const booleanParser = (val) => val === "true"; | ||
program.version("1.1.2").name("breezify"); | ||
program.version("1.1.3").name("breezify"); | ||
program | ||
@@ -15,0 +15,0 @@ .command("do") |
{ | ||
"name": "breezify", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "A tool for minifying CSS class names", | ||
@@ -60,2 +60,3 @@ "author": "Gleb Gorokhov <theververy@gmail.com>", | ||
"csso": "^5.0.5", | ||
"escape-string-regexp": "^5.0.0", | ||
"glob": "^10.3.10", | ||
@@ -62,0 +63,0 @@ "html-minifier": "^4.0.0", |
@@ -81,3 +81,5 @@ <img src="./logo_light.svg#gh-light-mode-only" alt="logo" width="200" /> | ||
webpack: (config) => { | ||
config.plugins.push(new BreezifyWebpack5Plugin()); | ||
if (config.mode === "production") { | ||
config.plugins.push(new BreezifyWebpack5Plugin()); | ||
} | ||
return config; | ||
@@ -100,3 +102,3 @@ }, | ||
- Work in progress... | ||
- See https://github.com/glebgorokhov/breezify-examples | ||
@@ -103,0 +105,0 @@ ## Ask Question or Discuss |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
148876
2800
339
16
+ Addedescape-string-regexp@^5.0.0
+ Addedescape-string-regexp@5.0.0(transitive)