Skip to content

Instantly share code, notes, and snippets.

@abitdodgy
Forked from raysegantii/README.md
Created November 8, 2016 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abitdodgy/3adfe959ff05a38b327361fd01ce06af to your computer and use it in GitHub Desktop.
Save abitdodgy/3adfe959ff05a38b327361fd01ce06af to your computer and use it in GitHub Desktop.
Use bootstrap-sass npm package with Phoenix's brunch
  1. install npm packages
  2. update brunch-config.js
  3. rename web/static/css/app.css to web/static/css/app.scss
  4. update web/static/css/app.scss
$icon-font-path: "/fonts/"; /* use fonts from priv/static/fonts/ */
@import "bootstrap"; /* imports node_modules/bootstrap-sass/assets/stylesheets/_bootstrap.scss */
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
}
}
}
npm install --save-dev sass-brunch copycat-brunch
npm install --save bootstrap-sass jquery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment