From 4aff5971d1c8f25c6a778e90ff397085cf4377d6 Mon Sep 17 00:00:00 2001 From: Ben Warren Date: Mon, 12 Jun 2017 12:38:00 -0400 Subject: [PATCH] Automatic recompilation of Bootstrap with user-defined variables (#1181) Allow for dynamic bootstrap compilation Exclude sublime artifacts Make custom bootstrap vars file Add custom bootstrap compilation Add cookiecutter option Use the right name for the file Add explanation to generated README Add self to contributors Remove sublime exclusion --- CONTRIBUTORS.rst | 1 + cookiecutter.json | 1 + {{cookiecutter.project_slug}}/Gruntfile.js | 6 +++ {{cookiecutter.project_slug}}/README.rst | 9 ++++ .../static/sass/custom_bootstrap_vars.scss | 0 .../static/sass/project.scss | 54 +++++++++++++++++++ 6 files changed, 71 insertions(+) create mode 100644 {{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/static/sass/custom_bootstrap_vars.scss diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 11324a50..215e58ee 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -56,6 +56,7 @@ Listed in alphabetical order. Areski Belaid `@areski`_ Ashley Camba Barclay Gauld `@yunti`_ + Ben Warren `@bwarren2` Ben Lopatin Benjamin Abel Bo Lopker `@blopker`_ diff --git a/cookiecutter.json b/cookiecutter.json index 4450e693..5b443493 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -21,5 +21,6 @@ "postgresql_version": ["9.6", "9.5", "9.4", "9.3", "9.2"], "js_task_runner": ["Gulp", "Grunt", "None"], "use_lets_encrypt": "n", + "custom_bootstrap_compilation": "n", "open_source_license": ["MIT", "BSD", "GPLv3", "Apache Software License 2.0", "Not open source"] } diff --git a/{{cookiecutter.project_slug}}/Gruntfile.js b/{{cookiecutter.project_slug}}/Gruntfile.js index e5fbccee..6900c4e0 100644 --- a/{{cookiecutter.project_slug}}/Gruntfile.js +++ b/{{cookiecutter.project_slug}}/Gruntfile.js @@ -60,6 +60,9 @@ module.exports = function (grunt) { dev: { options: { outputStyle: 'nested', +{% if cookiecutter.custom_bootstrap_compilation == 'y' %} + includePaths: ['bower_components/bootstrap-sass/assets/stylesheets/bootstrap/'], +{% endif %} sourceMap: false, precision: 10 }, @@ -70,6 +73,9 @@ module.exports = function (grunt) { dist: { options: { outputStyle: 'compressed', +{% if cookiecutter.custom_bootstrap_compilation == 'y' %} + includePaths: ['bower_components/bootstrap-sass/assets/stylesheets/bootstrap/'], +{% endif %} sourceMap: false, precision: 10 }, diff --git a/{{cookiecutter.project_slug}}/README.rst b/{{cookiecutter.project_slug}}/README.rst index 0248eee3..924e238d 100644 --- a/{{cookiecutter.project_slug}}/README.rst +++ b/{{cookiecutter.project_slug}}/README.rst @@ -145,3 +145,12 @@ See detailed `cookiecutter-django Elastic Beanstalk documentation`_. .. _`cookiecutter-django Docker documentation`: http://cookiecutter-django.readthedocs.io/en/latest/deployment-with-elastic-beanstalk.html {% endif %} +{% if cookiecutter.custom_bootstrap_compilation == "y" %} +Custom Bootstrap Compilation +^^^^^^ + +To get automatic Bootstrap recompilation with variables of your choice, install bootstrap sass (`bower install bootstrap-sass`) and tweak your variables in `static/sass/custom_bootstrap_vars`. + +(You can find a list of available variables [in the bootstrap-sass source](https://github.com/twbs/bootstrap-sass/blob/master/assets/stylesheets/bootstrap/_variables.scss), or get explanations on them in the [Bootstrap docs](https://getbootstrap.com/customize/).) + +{% endif %} diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/static/sass/custom_bootstrap_vars.scss b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/static/sass/custom_bootstrap_vars.scss new file mode 100644 index 00000000..e69de29b diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/static/sass/project.scss b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/static/sass/project.scss index 54632b2d..8dafa220 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/static/sass/project.scss +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/static/sass/project.scss @@ -1,3 +1,57 @@ +{% if cookiecutter.custom_bootstrap_compilation == 'y' %} +@import "variables"; +@import "custom_bootstrap_vars"; +@import "mixins"; + +// Reset and dependencies +@import "normalize"; +@import "print"; +@import "glyphicons"; + +// Core CSS +@import "scaffolding"; +@import "type"; +@import "code"; +@import "grid"; +@import "tables"; +@import "forms"; +@import "buttons"; + +// Components +@import "component-animations"; +@import "dropdowns"; +@import "button-groups"; +@import "input-groups"; +@import "navs"; +@import "navbar"; +@import "breadcrumbs"; +@import "pagination"; +@import "pager"; +@import "labels"; +@import "badges"; +@import "jumbotron"; +@import "thumbnails"; +@import "alerts"; +@import "progress-bars"; +@import "media"; +@import "list-group"; +@import "panels"; +@import "responsive-embed"; +@import "wells"; +@import "close"; + +// Components w/ JavaScript +@import "modals"; +@import "tooltip"; +@import "popovers"; +@import "carousel"; + +// Utility classes +@import "utilities"; +@import "responsive-utilities"; +{% endif %} + + // project specific CSS goes here