Home  >  Q&A  >  body text

Front-end - How to solve the background problem by merging multiple css addresses with nginx?

Node+Nginx project, the page uses http://cdn/project1/a.css, pro... such an address refers to css,
Each css may have a background with a relative path, such as background :url(./images/logo.png), after merging, the image path will report an error. Is there any way to solve it?

某草草某草草2714 days ago451

reply all(2)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-05-16 17:10:14

    1. Use absolute paths if possible

    2. If you cannot use absolute paths and cannot mix css from different directories, you can call them separately

      http://cdn/??a.css
      http://cdn/project/??1.css,2.css
    3. Build the same environment locally for testing, apache also has the concat component

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 17:10:14

    The relative path of the css file must be obtained based on the current css file. Just hang the corresponding pictures in the relative position on the cdn.

    reply
    0
  • Cancelreply