0

I am searching for a way to "(half)-automatically" copy CSS-code into an existing .CSS-file (e. g. via Batch File).

The problem beyond this is, that we are using an application we customized some existing stylesheets in (by "hand") - but however after every update of the application (which happens pretty often) the customizations are gone. We also didn't find any workaround to outsource for example our stylesheets. The application only supports the by manufacturer created stylesheet-files.

Simply replacing the css-files with same name is risky, because there are often new changes with new version of the application.

That is why we search for a simple way, by which we can insert some css-code to several css-files - as we don't always want to insert more than 1000 lines of CSS-Code into circa 10 different Stylesheet-files from the manufacturer.

If someone knows any other workaround which may work, I will also appreciate it.

6
  • 1
    In batch: echo "* {color: red !important;}" >> styles.css. But what kind of system is this? Try prepending @include: "../my-styles.css" Commented Jun 22, 2018 at 13:32
  • Thank you very much for the comment. It is Polarion ALM. Commented Jun 22, 2018 at 13:37
  • It works! You are amazing Commented Jun 22, 2018 at 13:45
  • One more question. This 2nd line of code you posted means I would affect another CSS-File with same changes or? Or how can I import for example this css to multiple css-files? Commented Jun 22, 2018 at 14:01
  • It will literally import your code to the beginning of file. All other CSS flow will be as is. Commented Jun 22, 2018 at 14:09

1 Answer 1

1

In batch to append something to file simply use >> command:

echo "* {color: red !important;}" >> styles.css

Or you can have somewhere your own CSS rules with higher priority then applications and use this code:

mv styles.css styles.css.tmp
echo '@import "../my-styles.css"' > styles.css
cat styles.css.tmp >> styles.css
rm styles.css.tmp

What it does:

  1. Copy existing css file to temporary file
  2. Write CSS @import rule as it must be in the beginning of file
  3. Append rest of CSS to your file from tmp file
  4. Remove temporary file

Move your my-styles.css to somewhere where application update would not overwrite it/remove it

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.