@nimpl/classnames-minifier 3.0.0 → 3.0.1-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ModuleOptions } from
|
|
2
|
-
import type ClassnamesMinifier from
|
|
1
|
+
import type { ModuleOptions } from "webpack";
|
|
2
|
+
import type ClassnamesMinifier from "classnames-minifier";
|
|
3
3
|
export declare type InjectConfig = {
|
|
4
4
|
localIdentName?: string;
|
|
5
5
|
classnamesMinifier: ClassnamesMinifier;
|
|
6
6
|
};
|
|
7
|
-
declare const injectConfig: (config: InjectConfig, rules?: ModuleOptions[
|
|
7
|
+
declare const injectConfig: (config: InjectConfig, rules?: ModuleOptions["rules"]) => void;
|
|
8
8
|
export default injectConfig;
|
package/dist/lib/injectConfig.js
CHANGED
|
@@ -4,21 +4,17 @@ const injectConfig = (config, rules) => {
|
|
|
4
4
|
var _a;
|
|
5
5
|
if (!rules)
|
|
6
6
|
return;
|
|
7
|
-
const oneOfRule = rules === null || rules === void 0 ? void 0 : rules.find((rule) => typeof rule ===
|
|
8
|
-
if (oneOfRule && typeof oneOfRule ===
|
|
7
|
+
const oneOfRule = rules === null || rules === void 0 ? void 0 : rules.find((rule) => typeof rule === "object" && typeof (rule === null || rule === void 0 ? void 0 : rule.oneOf) === "object");
|
|
8
|
+
if (oneOfRule && typeof oneOfRule === "object") {
|
|
9
9
|
const testCssLoaderWithModules = (loaderObj) => {
|
|
10
10
|
var _a;
|
|
11
|
-
return
|
|
12
|
-
((_a = loaderObj === null || loaderObj === void 0 ? void 0 : loaderObj.loader) === null || _a === void 0 ? void 0 : _a.match(
|
|
13
|
-
typeof loaderObj.options ===
|
|
14
|
-
loaderObj.options.modules
|
|
11
|
+
return typeof loaderObj === "object" &&
|
|
12
|
+
((_a = loaderObj === null || loaderObj === void 0 ? void 0 : loaderObj.loader) === null || _a === void 0 ? void 0 : _a.match("css-loader")) &&
|
|
13
|
+
typeof loaderObj.options === "object" &&
|
|
14
|
+
loaderObj.options.modules;
|
|
15
15
|
};
|
|
16
|
-
const testFontLoader = (loaderObj) => {
|
|
17
|
-
|
|
18
|
-
return (typeof loaderObj === 'object' &&
|
|
19
|
-
((_a = loaderObj === null || loaderObj === void 0 ? void 0 : loaderObj.loader) === null || _a === void 0 ? void 0 : _a.match('next-font-loader')));
|
|
20
|
-
};
|
|
21
|
-
(_a = oneOfRule.oneOf) === null || _a === void 0 ? void 0 : _a.forEach(rule => {
|
|
16
|
+
const testFontLoader = (loaderObj) => { var _a; return typeof loaderObj === "object" && ((_a = loaderObj === null || loaderObj === void 0 ? void 0 : loaderObj.loader) === null || _a === void 0 ? void 0 : _a.match("next-font-loader")); };
|
|
17
|
+
(_a = oneOfRule.oneOf) === null || _a === void 0 ? void 0 : _a.forEach((rule) => {
|
|
22
18
|
if (rule && Array.isArray(rule.use)) {
|
|
23
19
|
let cssLoaderIndex = null;
|
|
24
20
|
for (let i = rule.use.length - 1; i >= 0; i--) {
|
|
@@ -32,7 +28,7 @@ const injectConfig = (config, rules) => {
|
|
|
32
28
|
if (testFontLoader(loaderObj))
|
|
33
29
|
break;
|
|
34
30
|
if (testCssLoaderWithModules(loaderObj)) {
|
|
35
|
-
if (typeof loaderObj !==
|
|
31
|
+
if (typeof loaderObj !== "object" || typeof loaderObj.options !== "object")
|
|
36
32
|
continue;
|
|
37
33
|
cssLoaderIndex = i;
|
|
38
34
|
loaderObj.options.modules.getLocalIdent = config.classnamesMinifier.getLocalIdent;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Config } from
|
|
2
|
-
declare type PluginOptions = Omit<Config,
|
|
1
|
+
import type { Config } from "classnames-minifier/dist/lib/types/plugin";
|
|
2
|
+
declare type PluginOptions = Omit<Config, "cacheDir" | "distDir"> & {
|
|
3
3
|
disabled?: boolean;
|
|
4
4
|
};
|
|
5
5
|
declare const withClassnameMinifier: (pluginOptions?: PluginOptions) => (nextConfig?: any) => any;
|
|
@@ -12,9 +12,9 @@ const withClassnameMinifier = (pluginOptions = {}) => {
|
|
|
12
12
|
if (pluginOptions.disabled)
|
|
13
13
|
return nextConfig;
|
|
14
14
|
if (!classnamesMinifier) {
|
|
15
|
-
const distDir = (nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.distDir) ||
|
|
15
|
+
const distDir = (nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.distDir) || ".next";
|
|
16
16
|
const distDirAbsolute = path_1.default.join(process.cwd(), distDir);
|
|
17
|
-
const cacheDir = path_1.default.join(distDirAbsolute,
|
|
17
|
+
const cacheDir = path_1.default.join(distDirAbsolute, "cache/ncm");
|
|
18
18
|
classnamesMinifier = new classnames_minifier_1.default({
|
|
19
19
|
prefix: pluginOptions.prefix,
|
|
20
20
|
reservedNames: pluginOptions.reservedNames,
|
|
@@ -22,14 +22,14 @@ const withClassnameMinifier = (pluginOptions = {}) => {
|
|
|
22
22
|
cacheDir,
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
return
|
|
25
|
+
return Object.assign(Object.assign({}, nextConfig), { webpack: (config, options) => {
|
|
26
26
|
var _a;
|
|
27
27
|
(0, injectConfig_1.default)({ classnamesMinifier }, (_a = config.module) === null || _a === void 0 ? void 0 : _a.rules);
|
|
28
|
-
if (typeof nextConfig.webpack ===
|
|
28
|
+
if (typeof nextConfig.webpack === "function") {
|
|
29
29
|
return nextConfig.webpack(config, options);
|
|
30
30
|
}
|
|
31
31
|
return config;
|
|
32
|
-
} })
|
|
32
|
+
} });
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
35
|
exports.default = withClassnameMinifier;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nimpl/classnames-minifier",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1-canary.1",
|
|
4
4
|
"description": "Library for configuring style modules to generate compressed classes",
|
|
5
5
|
"main": "dist/withClassnamesMinifier.js",
|
|
6
6
|
"types": "dist/withClassnamesMinifier.d.ts",
|
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
|
-
"build": "tsc"
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"nimpl:classnames-minifier": "pnpm --filter @nimpl/classnames-minifier",
|
|
13
|
+
"lint": "eslint .",
|
|
14
|
+
"eslint": "eslint",
|
|
15
|
+
"prepare": "husky"
|
|
12
16
|
},
|
|
13
17
|
"keywords": [
|
|
14
18
|
"next",
|
|
@@ -38,7 +42,13 @@
|
|
|
38
42
|
"@types/uuid": "9.0.7",
|
|
39
43
|
"@types/webpack": "5.28.0",
|
|
40
44
|
"css-loader": "6.9.0",
|
|
41
|
-
"typescript": "4.5.4"
|
|
45
|
+
"typescript": "4.5.4",
|
|
46
|
+
"eslint": "8.57.0",
|
|
47
|
+
"eslint-config-prettier": "^9.1.0",
|
|
48
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
49
|
+
"husky": "^9.0.11",
|
|
50
|
+
"prettier": "^3.2.5",
|
|
51
|
+
"typescript-eslint": "^7.6.0"
|
|
42
52
|
},
|
|
43
53
|
"peerDependencies": {
|
|
44
54
|
"css-loader": ">=4.0.0"
|