bulma-variables-export
Library exporting Bulma sass variables which can be used in Webpack project. Bulma variables can be imported into any Javascript/Typescript project.
Quick install
NPM
npm install bulma-variables-export
Webpack Setup
When working with Javascript/Typescript and Sass, sometimes you want to be able to share variables defined in stylesheets with your code. This is actually pretty simple with Webpack.
First make sure webpack is set up to import scss:
// webpack.config.js
module.exports = {
...
module: {
rules: [{
test: /\.scss$/,
use: [{
loader: "style-loader" // creates style nodes from JS strings
}, {
loader: "css-loader" // translates CSS into CommonJS
}, {
loader: "sass-loader" // compiles Sass to CSS
}]
}]
}
};
import
Now you can import any Bulma variables in your project.
You can import every variables using:
import variables from 'bulma-variables-export'
You can also import specific set of variables using:
import initialVariables from 'bulma-variables-export/sass/initial-variables.scss'
import derivedVariables from 'bulma-variables-export/sass/derived-variables.scss'
import controlsVariables from 'bulma-variables-export/sass/controls-variables.scss'
Usage
Usage in your code is very simple. The variables name are exactly defined as Bulma but in camelCase.
import variables from 'bulma-variables-export'
// *OR*
// variables = require('bulma-variables-export');
console.log(variables.black)
console.log(variables.familyMonospace)
console.log(variables.weightMedium)
Exported object is always empty since an upgrade of Vue Cli services
Describe the bug I was using this package for quite a while to import initial Bulma variables for the CSS device breakpoints. Since I upgraded the vue-cli services to 5.0.4 the package doesn't seem to work anymore. I am not quite sure, which of the dependencies that were upgraded has broken it (sass-loader?) but the exported object is always empty for me.
vue.config.js
So nothing really special here.
component.vue
Expected behavior The inital variables object should contain all the variables that Bulma sets and this package exports.
Actual behavior The object is just empty
Screenshots
Desktop (please complete the following information):
Additional context package.json:
If you need more information to debug this, feel free to ask me