Comments (10)
Yes no problem. Anyways having same names for both classes and ids is very rare. I can edit manually the mapping for now and load it in future renamings. Thanks a lot :)
from node-rename-css-selectors.
I was wrong it is also saving the mapping for the id with your code above. I'm using
const loadedMapping = JSON.parse(
fs.readFileSync(path.resolve(YOUR_PATH, YOUR_FILENAME))
);
rcsCore.mapping.load(loadedMapping);
rcs.process
.auto(["**/**/*.css", "**/**/*.html"], options)
.then(() => {
const mappingToSave = rcsCore.mapping.generate();
fs.writeFileSync(YOUR_FILENAME, JSON.stringify(mappingToSave), "utf8");
log("done")
})
.catch((error) => {
log(error);
});
Had to use .parse and .stringify to avoid errors: [Object object] is not an object in mapping.load(), and data argument must be string in writeFileSync. But it saves everything in the mapping. Thanks again.
from node-rename-css-selectors.
I'm using
❯ yarn list rcs-core
yarn list v1.22.5
warning Filtering by arguments is deprecated. Please use the pattern option instead.
├─ [email protected]
└─ [email protected]
----└─ [email protected]
✨ Done in 0.15s.
❯ yarn list rename-css-selectors
yarn list v1.22.5
warning Filtering by arguments is deprecated. Please use the pattern option instead.
└─ [email protected]
✨ Done in 0.14s.
from node-rename-css-selectors.
Thanks for your issue. This seems to be a bug. To verify if that one is still occurring in the latest version, could you try the latest release v4.0.0-rc.2
or npm i rename-css-selectors@next
from node-rename-css-selectors.
With 4.0.0-rc.2
it does correctly use a different renaming for the id and classes in the html and css files but it does not save the mapping for the id in renaming-map.json
.
from node-rename-css-selectors.
Alright good to know. It seems I forgot to rewrite the mapping part here. Could you be so kind and write the config for now by yourself?
import rcsCore from 'rcs-core';
import fs from 'fs';
// better to use async methods but for the use case this is simpler
const loadedMapping = fs.readFileSync(YOUR_FILENAME, 'utf8')
// LOADING
rcsCore.mapping.load(loadedMapping);
// now do your rename-css-selectors magic
// e.g. rcs.process.auto(FILES)
// SAVING
const mappingToSave = rcsCore.mapping.generate();
// better to use async methods but for the use case this is simpler
fs.writeFileSync(YOUR_FILENAME, mappingToSave, 'utf8');
from node-rename-css-selectors.
Please be aware that the mappings between rename-css-selectors v3
and v4
will be different (in v4.0.0-rc.3
and above
from node-rename-css-selectors.
But the approach I sent will work in the future with stable v4
from node-rename-css-selectors.
Oh ya sorry that was my mistake, I didn't thought about this one. I am always using the fs-extra
s writeJson and readJson function, I guess this was the reason I forgot that part :)
from node-rename-css-selectors.
@personaaleatoria FYI
You can now use the new mapping function directly from rename-css-selectors
(this example with top-level await) with v4.0.0-rc.3
:
import rcs from 'rename-css-selectors';
import fs from 'fs';
// LOADING
await rcs.mapping.load(YOUR_FILENAME);
// process some files
await rcs.process.auto(FILES)
// SAVING
await rcs.mappings.generate(YOUR_FILENAME, { overwrite: true });
from node-rename-css-selectors.
Related Issues (20)
- 3.2.4 breaks calc with css variables HOT 2
- Messes up with the `~` character HOT 4
- Uncaught TypeError: (0 , r.default)(...).at is not a function HOT 4
- Ignore specific class HOT 1
- renaming html tags such as div HOT 3
- [BUG] It renames EJS HOT 7
- Add documentation for rcsCore usage in rename-css-selectors
- mismatched layout after running rcs HOT 3
- Integration with Gulp HOT 16
- Not completely renamed if there's a line break between class names HOT 6
- Exclude classes with special characters HOT 6
- [Q] Webpack Usage? HOT 6
- Does this plugin optimize the library so most frequent classes get one letter not two? HOT 2
- Minify as a function HOT 2
- Bug: Textarea and other common words replaced HOT 3
- Unused css selectors given a one letter selector - is sorting by frequency working correctly? HOT 4
- getElementById string being replaced by class selector name instead of id
- Unchanging custom class name HOT 1
- Is it possible to use rcs-core with vite/rollup)?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-rename-css-selectors.