Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate prefix for .js and .css #11

Open
striveforbest opened this issue Feb 9, 2018 · 3 comments
Open

Separate prefix for .js and .css #11

striveforbest opened this issue Feb 9, 2018 · 3 comments

Comments

@striveforbest
Copy link

It would be amazing to have an ability to set NPM_STATIC_FILES_PREFIX per filetype.

@ramabouda
Copy link
Collaborator

Without a doubt, but I think we want to keep this package as simple as possible. Unless you convince me it's a game changer, of course :)

@striveforbest
Copy link
Author

You have a point @raphael-boucher :)
uhmm, i don't know if I have a very strong argument. But one good use I found is to put external libraries in, let's say fontawesome-all.js, static/lib/fontawesome/, then set NPM_STATIC_FILES_PREFIX to lib as well, after running collecstatic, you'll end up with all of your 3rd-party dependencies under <collected_static>/lib which is amazing. But, yeah, it would be even better to have stuff under <collected_static>/lib/<package_name>/js and <collected_static>/lib/<package_name>/css, looks much nice in the templates when you reference the files.

And that can be an optional setting, just an expansion of what is already there, similar to your NPM_FILE_PATTERNS.

Regardless, thanks for your work, guys!

@vstoykov
Copy link

For simple packages which provide only js or only css or both but not images and or fonts this sounds cool, but as general approach is not because other files referenced by the css can be placed at the wrong place.

At the end it is responsibility of the package owner to structure it's package/library. For example Bootstrap has css and js in it's dist folder. Then if you set NPM_STATIC_FILES_PREFIX to vendor you will end up with /static/vendor/bootstrap/dist/css/bootstrap.min.css and similar for the js which is cool.

Probably better improvement will be not only to tell which files the package you want in NPM_FILE_PATTERNS but also how to copy them in your static. Again with the example with the bootstrap I put the following:

NPM_FILE_PATTERNS = {
    'jquery': ['dist/*'],
    'bootstrap': ['dist/*']
}

And I ended up with /static/vendor/jquery/dist/jquery.min.js and I already said about bootstrap, but will be better if we can remove dist somehow from the resulting path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants