I am creating Shopify theme using slate, I want to add bootstrap 4 SCSS in my theme
I have tried this by adding bootstrap’s SCSS folder in styles/vendor/bootstrap
folder and import it in theme.scss
/*================ BOOTSTRAP ================*/
@import url('vendor/bootstrap/scss/bootstrap.scss');
the issue is that after including this slate build
successfully done but it gives an error in the console
Refused to apply style from 'https://cdn.shopify.com/s/files/1/2331/3377/t/10/assets/theme.scss.css?9739733336988663236' because its MIME type ('text/plain') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
and when I open CSS it shows
Failed to compile SCSS file
Can anyone have the solution for this? or any other method for import bootstrap 4 in slate theme
2
Answers
@import
is not supported by Shopify in SASS files.You must load your file separately in Theme.liquid layout.
You will need to @import each file using the url() method since Slate can’t parse normal sass file imports. Don’t forget that this applies to all the mixins and utilities that Bootstrap includes using this method as well.
Short Answer
Copy the imports from bootstrap.scss, mixins.scss and utilities.scss to /your-theme-root/src/styles/theme.scss and adjust the import syntax and paths.
Example
The following example assumes that you have copied the entire contents of bootstrap/scss to /your-theme-root/src/styles/vendor/bootstrap rather than including the entire Bootstrap repository — you will need to insert /scss/ for the following to work with your current paths.
Change this:
To this: