Kamuran Sönecek Kamuran Sönecek - 8 months ago 195
CSS Question

How to Export styles as css file in Angular 4

I am new in Angular 4 and I want to export my styles as

When I serve or build the project, it creates a
file and add css' as html style element. But I want to export as stylesheet file and load it with

My Angular-cli.json :

"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "ares"
"apps": [
"root": "src",
"outDir": "dist/desktop",
"assets": [
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"scripts": [
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
"lint": [
"project": "src/tsconfig.app.json",
"exclude": "**/node_modules/**"
"project": "src/tsconfig.spec.json",
"exclude": "**/node_modules/**"
"project": "e2e/tsconfig.e2e.json",
"exclude": "**/node_modules/**"
"test": {
"karma": {
"config": "./karma.conf.js"
"defaults": {
"styleExt": "scss",
"component": {}

Answer Source

When you running ng build or ng seve it always create a bundle like styles.bundles.js just for sake of saving some time on dev build. From another hand, if you do ng build --prod it will produce styles.bundle.css.

If you want styles.bundle.css to be produced for your dev build then just add --extract-css flag e.g ng seve --extract-css.

Here is some more details on default flags that might be helpful:

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download