Code Monkey home page Code Monkey logo

Comments (6)

gensmann avatar gensmann commented on July 30, 2024 2

I'll second a vote for a way to concatenate the files before pre-compiling. This would be very helpfull when using less etc. since a standway is to keep mixins and global variables in one file and merge it in before compiling. Right now you have to repeat those vars and mixins in every css file ie if you have a set of skin color global vars that is used in multiple css files, which sort of ruins the purpose of using global vars in css frameworks like sass or less, unless you keep everything in one file.

I understand the problem hvdklauw mentions, so maybe it could be an option on each compress block wether or not to merge before pre-compiling or after?

from django-compressor.

sicarrots avatar sicarrots commented on July 30, 2024 2

It is very important when using css preprocessors such less, its 'core' feauture is allowing to use mixins. Therefore concatenting files before processing through filter is a must-have functionality. Is there any plans to merge @jannon requests do dev branch django_compressor?

from django-compressor.

hvdklauw avatar hvdklauw commented on July 30, 2024

Hmm that's exactly what I wouldn't want.

What if they aren't in the same base path, and have the same @import statements but referencing different files because they are in different paths.

Right now @import doesn't even work because the content of the file is written to a temporary file before being passed to the processor.

I say process the files one by one and then concatenate so all references for compilation is correct.

from django-compressor.

jezdez avatar jezdez commented on July 30, 2024

@gensmann Adding an option to the compress block sounds like a plan, yup.

from django-compressor.

airtonix avatar airtonix commented on July 30, 2024

with regards to Sass, my approach to this is to define all the includepaths for the sass binary then @import the other files in my scss files:

# app/settings/common.py
...
scss_args = " ".join(["--include-path %s/vendor/bourbon/app/assets/stylesheets/" % VENDOR_ROOT,
                      "--include-path %s/vendor/bootstrap-sass-official/vendor/assets/stylesheets/" % VENDOR_ROOT])
...

COMPRESS_PRECOMPILERS = (
    ('text/coffeescript', 'node_modules/.bin/coffee --compile --stdio'),
    ('text/x-scss', 'node_modules/.bin/node-sass %s {infile} {outfile}' % scss_args)
)
...
// app/common/static/css/screen.scss
@import url("http://fonts.googleapis.com/css?family=Montserrat:400,700");
@import "./vendor.scss";
@import "./elements.scss";
@import "./pages.scss";

body, html {
    font-family: 'Montserrat';
}
// app/common/static/css/vendor.scss
@import "_bourbon.scss";
@import "bootstrap.scss";
<! -- app/common/templates/base.html -->
...
{% compress css %}
<link href="{% static 'css/screen.scss' %}" type='text/x-scss' media='screen, projector' rel='stylesheet'>
{% endcompress %}
...

from django-compressor.

k-funk avatar k-funk commented on July 30, 2024

@airtonix I started doing this, but the changes to any @import'ed files don't get watched, and so the server needs to be restarted for every css change in them.
Kinda amazed this feature hasn't been implemented yet. webassets solved this, allowing users to use SASS_AS_OUTPUT = True, which optionally concats the files first.

from django-compressor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.