Comments (6)
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.
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.
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.
@gensmann Adding an option to the compress block sounds like a plan, yup.
from django-compressor.
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.
@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)
- Slim down package HOT 1
- Add support for django 4.2 HOT 1
- Replace deprecated imp module with importlib HOT 2
- Django's `get_storage_class` is deprecated in 4.2 (Django 5.1 compat.) HOT 5
- Releasing a new version with Django 4.2 support HOT 3
- No way to specify hashing method for JS files? HOT 1
- Disable offline compression for some scripts HOT 5
- Fix tests with Python 3.9.17, 3.10.12 and 3.11.4 HOT 7
- Dependencies are pinned HOT 1
- Dynamic SCRIPT_NAME and compressed assets HOT 8
- Getting more info when `Error parsing template` happens
- Not compatible with django-components HOT 10
- Issue with losing templates in compress command in version >=3.0.
- optional max_workers for compress command HOT 1
- 'Settings' object has no attribute 'COMPRESSORS' HOT 8
- OSSFuzz Integration HOT 4
- 4.4: compressor.exceptions.OfflineGenerationError raised in tests HOT 4
- Django 5.1 compatibility HOT 1
- Offline compression + inlining bug HOT 3
- Compress command: warn or error about context vars?
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 django-compressor.