npm-css import not entire file of bootstrap.css - css

I have Ionic app and trying to use Datepicker from Angular UI Bootstrap. It doesn't have own style files and uses bootstrap.css. So I installed bootstrap and try to import style file with npm-css in my index.css file:
#import "bootstrap";
then I use
npm-css index.css -o bundle.css
Issue is that bundle.css file contain not entire bootstrap.css file.
Only errors in console are about bootstrap glyphicons and I think this is not related with my problem.
Before this I used npm-css without any problems.

It seems there is issue with npm-css and I can't catch it. But when I switch to rework-npm all entire file is imported and all working fine.

Related

Angular (13) Material - override CSS file doesn't work

I have a simple Angular (13) application with Material.
I've created a CSS file that is meant for overriding some of the Material styles, and imported it into styles.scss. This import is the last line of this file.
Yet, none of the CSS definitions in the external file seem to actually override the existing styles from Material.
When I place these definitions directly in styles.scss, they work.
What is the difference between importing CSS definitions from a file and placing them directly, in this case? Am I missing something here?
To import css to an scss file, you should import it without the extension like this.
#import "path/to/file/file_name_without_extension"
If you import that with extension
#import "path/to/file/file_name.css"
it won't work as it gets translated to
#import url(path/to/file/file_name.css);
Merged PR from SASS repo: Implement raw css imports

Organize application SASS files using Bootstrap

I'm starting to work on a large application styling files. As Bootstrap 4 offers SASS files, I decided to follow that path.
I have built the following files structure:
theme.scss: general definitios for the theme like colors and fonts. Today there is just one but there could be more in the future.
global.scss: includes Bootstrap, some Bootstrap overrides and application componentes -i.e. a field with its label as part of the top border.
site.scss: general application styles.
additional page-specific SCSS files. I.e.: login.scss.
The problem I'm having is that global.scss -the one that imports Bootstrap- is then imported by site.scss as well as other files like page-specific SCSS files. So, Bootstrap styles end up in more than one compiled CSS. Compiled CSS files are what the application actually references.
I've previously used LESS and I could solve this using #import (reference) "bootstrap" instead of just plain #import "bootstrap". With SASS I haven't been able to find any solution to this problem without modifying Bootstrap core files.
Is there any other recommended way to organize the files and avoid this problem? Am I missing something or doing anything wrong?
Here are the files contents (they are large files but I'm posting only enough contents to show the problem I'm having):
theme.scss
$my-primary-color: #04459a;
global.scss
#import "../theme.scss";
$primary: $my-primary-color;
#import "../../third-party/bootstrap/scss/bootstrap.scss";
%field{
// [...]
}
site.scss
#import "global.scss";
div.field {
#extend %field;
}
// [...]
login.scss (or many other)
#import "global.scss";
// [...]
In the application I'm referencing site.css and login.css (in the loign page, of course) and both of them include Bootstrap styles.
I've built something that works for me, not sure if it's the best solution or which drawbacks it has, though.
I took some ideas from this article: My favored SCSS setup with Bootstrap 4. Here's what I've built:
First I created two SASS files for importing Bootstrap (similar to what the article does with bootstrap/_config.scss but splitted):
bootstrap/_sass-componentes.scss
#import "../../terceros/bootstrap/scss/_functions.scss";
#import "../../terceros/bootstrap/scss/_variables";
#import "../../terceros/bootstrap/scss/_mixins";
bootstrap/_config.scss
#import "_sass-componentes.scss";
// Every other bootstrap file I want to include:
#import "../../terceros/bootstrap/scss/_root";
#import "../../terceros/bootstrap/scss/_reboot";
#import "../../terceros/bootstrap/scss/_type";
// [...]
#import "../../terceros/bootstrap/scss/_utilities";
#import "../../terceros/bootstrap/scss/_print";
Then in global.scss I changed the bootstrap.scss import line to import only bootstrap/_sass-componentes.scss
Finally, in site.scss I included global.scss (such as it was before) and then full Bootstrap files trough bootstrap/_config.scss. **
** After importing _config.scss I also import my Bootstrap customizations. For doing them I followed the recomendation of the linked article although they do not apply directly to my own question.

Style of React component is not working on Heroku

index.jsx
import 'react-date-range/dist/styles.css'
import 'react-date-range/dist/theme/default.css'
I deployed a Rails app(Rails + React.js) on Heroku.
But styles of react-date-range component are not loaded on Heroku even it is working on local.
What is the way to fix this issue?
Obviously, you're using Webpack and you have configs for loading CSS, instead of using index.jsx add these two pre-compiled CSS into your root of CSS by this:
#import url("react-date-range/dist/styles.css");
#import url("react-date-range/dist/theme/default.css");
If the url function doesn't work try without it:
#import "react-date-range/dist/styles.css";
#import "react-date-range/dist/theme/default.css";
If these two guys aren't in your final bundle file, simply, use relative path, because it is a little hard to add Webpack configuration that Webpack understand node_modules absolute path of libraries inside css-loader.
#import "../node_modules/react-date-range/dist/styles.css";
#import "../node_modules/react-date-range/dist/theme/default.css";

create-react-app npm run build wrong css order

I got in my index.js
import './styles/index.css';
import './styles/responsive.css';
the index.css contains browser desktop styling while the responsive.css will overwrite when the screen gets smaller like in mobile.
In development this works just fine, but using the compiled css after running npm run build makes the responsive styling messed up. After trying to debug I found that in build/static/css/main*.chunk.css the entries from responsive.css went first than the index.css and that created the problem.
is there any way to correct the issue? i could combine the responsive.css into index.css but I feel that's just a workaround
I believe there is no answer to your question. If you google for 'wrong css order' you may found github issues for webpack older than 2 years. Like that one https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/548 and there are many others.
I have solved this by combining styles into one file. I use scss so did something like:
// main.scss
#import 'globals';
#import 'responsive';
and in js
import main.scss

CSS files in sass folder - laravel

I was learning about Laravel Mix that allows us to compile Javascript and CSS files in our project. As I see, in resources/js folder, we can put all the javascript files that should be compiled and in resources/sass folder - all the css files. Using webpacker.mix.js, we import everything in app.js and app.scss but what I want to know is the following: Since, sass files are compiled into CSS, is it possible to import CSS files (and not SASS files) in app.scss? For example, to have this in app.scss:
#import ('css/style.css')
and not
#import ('css/style.scss')
?
Import is not a sass, but a plain css rule. You can use it to import normal css files, yes.

Resources