- install npm packages
- update brunch-config.js
- rename web/static/css/app.css to web/static/css/app.scss
- update web/static/css/app.scss
-
-
Save raysegantii/c1bd7e2ba55413a0c130f7316b5c7a13 to your computer and use it in GitHub Desktop.
Use bootstrap-sass npm package with Phoenix's brunch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$icon-font-path: "/fonts/"; /* use fonts from priv/static/fonts/ */ | |
@import "bootstrap"; /* imports node_modules/bootstrap-sass/assets/stylesheets/_bootstrap.scss */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.config = { | |
// See http://brunch.io/#documentation for docs. | |
files: { | |
javascripts: { | |
joinTo: "js/app.js" | |
}, | |
stylesheets: { | |
joinTo: "css/app.css", | |
order: { | |
after: ["web/static/css/app.scss"] // concat app.css last | |
} | |
}, | |
templates: { | |
joinTo: "js/app.js" | |
} | |
}, | |
conventions: { | |
assets: /^(web\/static\/assets)/ | |
}, | |
// Phoenix paths configuration | |
paths: { | |
// Dependencies and current project directories to watch | |
watched: [ | |
"web/static", | |
"test/static" | |
], | |
// Where to compile files to | |
public: "priv/static" | |
}, | |
plugins: { | |
babel: { | |
ignore: [/web\/static\/vendor/] | |
}, | |
copycat: { | |
"fonts": ["node_modules/bootstrap-sass/assets/fonts/bootstrap"] // copy node_modules/bootstrap-sass/assets/fonts/bootstrap/* to priv/static/fonts/ | |
}, | |
sass: { | |
options: { | |
includePaths: ["node_modules/bootstrap-sass/assets/stylesheets"], // tell sass-brunch where to look for files to @import | |
precision: 8 // minimum precision required by bootstrap-sass | |
} | |
} | |
}, | |
modules: { | |
autoRequire: { | |
"js/app.js": ["web/static/js/app"] | |
} | |
}, | |
npm: { | |
enabled: true, | |
globals: { // bootstrap-sass' JavaScript requires both '$' and 'jQuery' in global scope | |
$: 'jquery', | |
jQuery: 'jquery', | |
bootstrap: 'bootstrap-sass' // require bootstrap-sass' JavaScript globally | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install --save-dev sass-brunch copycat-brunch | |
npm install --save bootstrap-sass jquery |
Thanks. Works perfectly !!
thanks!
Thanks for this. I've been scratching my head on the least painful way to do this.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updates:
whitelist
, https://github.com/brunch/brunch/blob/master/CHANGELOG.md#brunch-22-jan-22-2016