Reading the angular-cli documentation and some discussion on stack overflow I had understand that when a project is done with generated components, the inline styles will be all included in the build by default, but when I build my project it seems that none of the inline styles were included.
For example this component:
import { MenubarService } from '../../services/menubar-service/menubar.service'
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css'],
providers:[LoginService]
})
export class LoginComponent implements OnInit {
constructor(.......
the login.component.css file is not present in the final project. I have noticed it for two reason:
First clearly the style of my app is different from the one that I have when I use 'ng serve' command and second because with the browser inspector element I don't find trace of my css.
That's my angular-cli's configuration file
{
"project": {
"version": "1.0.0-beta.18",
"name": "genioimprese"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"images",
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"mobile": false,
"styles": [
"styles.css",
"paper.css"
],
"scripts": [],
"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"addons": [],
"packages": [],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"prefixInterfaces": false,
"inline": {
"style": false,
"template": false
},
"spec": {
"class": false,
"component": true,
"directive": true,
"module": false,
"pipe": true,
"service": true
}
}
}
except for some styles and assets it's clearly the default file of a new angular-cli projects. I think there's something wrong in my configuration file but the only documentation that I found is here, and I didn't find anything that helps me.
a{
color: #0c699e;
}
a:hover,a:active,a:focus{
color: #218fce;
}
.login{
text-align: center;
background-color: white;
height: 100%;
padding-top: 7%;
}
.login > .logo{
height: 30%;
width: 50%;
}
.input[type='text']{
background-color: grey;
color: #218fce;
border: none;
border-radius: 0;
}
h4{
color: #218fce;
}
.form-group{
margin-bottom: 10px;
}
form{
margin-bottom: 0px;
}
.checkbox-inline{
margin: 0;
}
I know this is an old question but Angular's CLI now includes some CSS optimization options which just now caused my app's global stylesheet to output as media=print
.
Despite having NO print MQs, this media attr obviously causes no styles to be applied.
<link rel="stylesheet" ... href="styles.css" media="print">
"architect": ...
"build": ...
"configurations": {
"dev": {
...
"optimization": {
"scripts": true,
"styles": {
"minify": true,
"inlineCritical": false <--- fix
},
"fonts": true
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With