This Tech Bite was brought to you by Kenan Klisura, Lead Software Engineer at Atlantbh.
Tech Bites are tips, tricks, snippets or explanations about various programming technologies and paradigms, which can help engineers with their everyday job.
Bootstrap partial Sass
Bootstrap is a component-based library for developing web UI. Not all components are used when developing frontend with Bootstrap. In order to minimize the number of unused styles in a project, create a single sass file with custom imports of bootstrap components. Start with adding bootstrap as npm/yarn dependency, copy contents of a bootstrap.scss (defined in bootstrap/sass directory of node_modules) to a new file and change the imports path accordingly. The following is an example of the sass file that imports some bootstrap components:
// styles/bootstrap/_bootstrap.scss // Import constants overrides @import './constants; // Import bootstrap components @import '~bootstrap/scss/functions'; @import '~bootstrap/scss/variables'; @import '~bootstrap/scss/mixins'; @import '~bootstrap/scss/root'; // styles/bootstrap/_constants.scss $body-bg: red;
The ~ (tilde) is used for resolving from node_modules and is supported by sass-loader (webpack). For ember.js use ember-cli-bootstrap-sassy dependency, but without the tilde prefix.
Whenever you start a new project, start by using ESLint and adhere to its rules.