classnames-minifier 0.1.3 → 0.1.4-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.
- package/README.md +1 -0
- package/dist/lib/types/plugin.d.ts +1 -0
- package/dist/lib/validateDist.js +12 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,6 +29,7 @@ yarn add classnames-minifier
|
|
|
29
29
|
* `reservedNames` - array of reserved names that should not be used by this package (must include prefix);
|
|
30
30
|
* `cacheDir` - directory where this library will write the cache. Passing this parameter will enable caching. Use this option only if your framework really needs it;
|
|
31
31
|
* `distDir` - directory where the project is being assembled. Used only when caching is enabled to synchronize caches between this library and the project;
|
|
32
|
+
* `disableDistDeletion` - option that allows you to disable the automatic deletion of the dist folder if necessary (*f.e. differences in package setup in cache and now or first launch*);
|
|
32
33
|
|
|
33
34
|
Configuration example:
|
|
34
35
|
```js
|
package/dist/lib/validateDist.js
CHANGED
|
@@ -17,7 +17,7 @@ const readManifest = (manifestPath) => {
|
|
|
17
17
|
};
|
|
18
18
|
const validateDist = (pluginOptions) => {
|
|
19
19
|
var _a, _b, _c;
|
|
20
|
-
const { cacheDir, distDir, prefix, reservedNames } = pluginOptions;
|
|
20
|
+
const { cacheDir, distDir, prefix, reservedNames, disableDistDeletion } = pluginOptions;
|
|
21
21
|
if (!cacheDir || !distDir) {
|
|
22
22
|
console.log("classnames-minifier: Failed to check the dist folder because cacheDir or distDir is not specified");
|
|
23
23
|
return;
|
|
@@ -44,6 +44,9 @@ const validateDist = (pluginOptions) => {
|
|
|
44
44
|
if (prevData.version !== configuration_1.CODE_VERSION) {
|
|
45
45
|
configDiffMessages.push(`Different package version: "${prevData.version}" -> "${configuration_1.CODE_VERSION}"`);
|
|
46
46
|
}
|
|
47
|
+
if (prevData.disableDistDeletion && !disableDistDeletion) {
|
|
48
|
+
configDiffMessages.push(`"disableDistDeletion" set to "${disableDistDeletion}"`);
|
|
49
|
+
}
|
|
47
50
|
if (configDiffMessages.length) {
|
|
48
51
|
configurationError = `Changes found in package configuration: \n${configDiffMessages.map((message) => `- ${message};\n`)}`;
|
|
49
52
|
}
|
|
@@ -52,9 +55,14 @@ const validateDist = (pluginOptions) => {
|
|
|
52
55
|
configurationError = `Can not find the package cache manifest at ${manifestPath}\n`;
|
|
53
56
|
}
|
|
54
57
|
if (configurationError) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
if (!disableDistDeletion) {
|
|
59
|
+
console.log(`classnames-minifier: ${configurationError}Cleaning the dist folder...`);
|
|
60
|
+
fs_1.default.rmSync(distDir, { recursive: true, force: true });
|
|
61
|
+
console.log("classnames-minifier: Dist folder cleared");
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
console.log(`classnames-minifier: ${configurationError}"disableDistDeletion" option was set to true`);
|
|
65
|
+
}
|
|
58
66
|
}
|
|
59
67
|
if (!fs_1.default.existsSync(manifestDir))
|
|
60
68
|
fs_1.default.mkdirSync(manifestDir, { recursive: true });
|
package/package.json
CHANGED