Ionic Angular custom fonts not begin loaded - css

The Problem
No matter what i do, there is no way to make iOS Simulator load the custom fonts.
I've tested everything I've found across different Ionic versions and all platforms and the current setup works perfectly in Google Chrome Browser, Safari Browser, Android Device and Android Emulator but not in iOS Simulator (could not test it in iOS Device since i don't have one yet).
Expected Behavior
Current Behavior
No custom font dependent component is shown except when commenting its font styling (second image).
Code
Angular-Ionic mandatory global.scss (with repeated styling just to test if its correctly loaded only from certain sources)
// http://ionicframework.com/docs/theming/
#import '~#ionic/angular/css/core.css';
#import '~#ionic/angular/css/normalize.css';
#import '~#ionic/angular/css/structure.css';
#import '~#ionic/angular/css/typography.css';
#import '~#ionic/angular/css/padding.css';
#import '~#ionic/angular/css/float-elements.css';
#import '~#ionic/angular/css/text-alignment.css';
#import '~#ionic/angular/css/text-transformation.css';
#import '~#ionic/angular/css/flex-utils.css';
#import '~animate.css/animate.min';
#font-face {
font-family: "Gotham";
src: local('GothamMedium'), local('GothamMedium'),
url('assets/GothamMedium.eot') format('embedded-opentype'),
url('assets/GothamMedium.woff2') format('woff2'),
url('assets/GothamMedium.woff') format('woff'),
url('assets/GothamMedium.ttf') format('truetype'),
url('assets/GothamMedium.svg#GothamMedium') format('svg');
font-weight: normal;
font-style: normal;
}
#font-face {
font-family: "Gotham";
src: local('GothamBold'), local('GothamBold'),
url('assets/GothamBold.eot') format('embedded-opentype'),
url('assets/GothamBold.woff2') format('woff2'),
url('assets/GothamBold.woff') format('woff'),
url('assets/GothamBold.ttf') format('truetype'),
url('assets/GothamBold.svg#GothamBold') format('svg');
font-weight: bold;
font-style: normal;
}
#mixin font($weight, $size: false, $shadow: false, $align: false) {
font-family: "Gotham" !important;
font-weight: $weight;
#if $weight==regular {
#if $shadow {
text-shadow: 1px 1px 1px #aaaa;
}
}
#if $weight==bold {
#if $shadow {
text-shadow: 1px 2px 4px #aaaa;
}
}
#if $size {
font-size: $size !important;
}
#if $align {
text-align: $align !important;
}
}
//...
/*:root[mode=ios] .gotham,
:root[mode=md] .gotham{
--ion-font-family: 'Gotham' !important;
font-family: 'Gotham' !important;
}*/
}
.subtitulo {
#include font(normal, 3.5vw, false, center);
margin: auto !important;
}
ion-card-title,
h1 {
top: -10px;
#include font(bold, 9vw, true);
color: var(--ion-color-primary);
}
Ionic mandatory theming variables.scss
// Ionic Variables and Theming. For more info, please see:
// http://ionicframework.com/docs/theming/
/** Ionic CSS Variables **/
:root {
// --ion-font-family: "GothamMedium", "Roboto";
// font-family: var(--ion-font-family) !important;
--ion-font-family: 'Gotham' !important;
font-family: 'Gotham' !important;
//... other non-related theming variables
}
Ionic-suggested fonts.scss (i was going to deprecate it if the globals.scss code block functioned correctly, or the inverse). I do use mixins to make styling faster.
#font-face {
font-family: "Gotham";
src: local('GothamMedium'), local('GothamMedium'),
url('../assets/GothamMedium.eot') format('embedded-opentype'),
url('../assets/GothamMedium.woff2') format('woff2'),
url('../assets/GothamMedium.woff') format('woff'),
url('../assets/GothamMedium.ttf') format('truetype'),
url('../assets/GothamMedium.svg#GothamMedium') format('svg');
font-weight: normal;
font-style: normal;
}
#font-face {
font-family: "Gotham";
src: local('GothamBold'), local('GothamBold'),
url('../assets/GothamBold.eot') format('embedded-opentype'),
url('../assets/GothamBold.woff2') format('woff2'),
url('../assets/GothamBold.woff') format('woff'),
url('../assets/GothamBold.ttf') format('truetype'),
url('../assets/GothamBold.svg#GothamBold') format('svg');
font-weight: bold;
font-style: normal;
}
#mixin font($weight, $size: false, $shadow: false, $align: false) {
font-family: "Gotham" !important;
font-weight: $weight;
#if $weight==regular {
#if $shadow {
text-shadow: 1px 1px 1px #aaaa;
}
}
#if $weight==bold {
#if $shadow {
text-shadow: 1px 2px 4px #aaaa;
}
}
#if $size {
font-size: $size !important;
}
#if $align {
text-align: $align !important;
}
}
Configuration
angular.json
{
"$schema": "./node_modules/#angular-devkit/core/src/workspace/workspace-schema.json",
"version": 1,
"defaultProject": "app",
"newProjectRoot": "projects",
"projects": {
"app": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "#angular-devkit/build-angular:browser",
"options": {
"outputPath": "www",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
{
"glob": "**/*",
"input": "src/assets/",
"output": "assets/"
},
{
"glob": "**/*.woff2",
"input": "src/assets/",
"output": "assets/"
},
{
"glob": "**/*.svg",
"input": "node_modules/ionicons/dist/ionicons/svg",
"output": "./svg"
},
{
"glob": "**/*.svg",
"input": "node_modules/ionicons/dist/ionicons/svg",
"output": "./svg"
}
],
"styles": [
{
"input": "src/theme/fonts.scss"
},
{
"input": "src/theme/variables.scss"
},
{
"input": "src/global.scss"
},
//...
package.json
{
"name": "app",
"version": "0.1.0",
"author": "",
"homepage": "",
"scripts": {
"ng": "ng",
"start": "ng serve --host 0.0.0.0",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"android:dev": "ionic cordova run android --external --debug",
"android:prod": "ionic cordova run android -l --ssl --external --prod",
"ios:dev": "ionic cordova run ios --prod",
"ios:prod": "ionic cordova run ios -l --ssl --external --prod",
},
"private": true,
"dependencies": {
"#angular/common": "^10.1.5",
"#angular/core": "^10.1.5",
"#angular/forms": "^10.1.5",
"#angular/platform-browser": "^10.1.5",
"#angular/platform-browser-dynamic": "^10.1.5",
"#angular/router": "^10.1.5",
"#ionic-native/bluetooth-serial": "^5.28.0",
"#ionic-native/core": "5.22.0",
"#ionic-native/device": "^5.28.0",
"#ionic-native/diagnostic": "^5.28.0",
"#ionic-native/firebase-x": "^5.26.0",
"#ionic-native/in-app-browser": "^5.26.0",
"#ionic-native/native-storage": "^5.26.0",
"#ionic-native/splash-screen": "5.22.0",
"#ionic-native/status-bar": "^5.22.0",
"#ionic/angular": "^5.0.4",
"#ionic/storage": "^2.2.0",
"#keyframes/core": "^2.0.10",
"#teamhive/lottie-player": "^1.0.0",
"animate.css": "^3.7.2",
"cordova": "^10.0.0",
"cordova-android-firebase-gradle-release": "^4.0.0",
"cordova-plugin-bluetooth-serial": "^0.4.7",
"cordova-plugin-device": "^2.0.3",
"cordova-plugin-enable-multidex": "^0.2.0",
"cordova-plugin-inappbrowser": "^4.0.0",
"cordova-plugin-ionic-keyboard": "^2.2.0",
"cordova-plugin-ionic-webview": "^5.0.0",
"cordova-plugin-nativestorage": "^2.3.2",
"cordova-plugin-splashscreen": "^5.0.3",
"cordova-plugin-statusbar": "^2.4.3",
"cordova-plugin-whitelist": "^1.3.4",
"core-js": "^3.6.4",
"firebase": "^7.14.5",
"howler": "^2.1.3",
"keyframes": "^2.3.0",
"lodash": "^4.17.19",
"native-run": "^1.0.0",
"ng-payment-card": "0.0.8",
"npm-check-updates": "^4.0.4",
"rxjs": "^6.5.4",
"zone.js": "^0.10.2"
},
"devDependencies": {
"#angular-devkit/architect": "^0.900.5",
"#angular-devkit/build-angular": "^0.1001.6",
"#angular-devkit/core": "^10.1.6",
"#angular-devkit/schematics": "^10.1.6",
"#angular/cli": "^10.1.6",
"#angular/compiler": "^10.1.5",
"#angular/compiler-cli": "^10.1.5",
"#angular/language-service": "^10.1.5",
"#ionic/angular-toolkit": "^2.2.0",
"#ionic/lab": "^3.1.6",
"#types/jasmine": "^3.5.8",
"#types/jasminewd2": "^2.0.8",
"#types/lodash": "^4.14.149",
"#types/node": "^13.7.7",
"codelyzer": "^5.2.1",
"cordova-android": "^9.0.0",
"cordova-ios": "^6.1.1",
"cordova-plugin-androidx": "^2.0.0",
"cordova-plugin-androidx-adapter": "^1.1.1",
"cordova-plugin-firebasex": "10.2.0-cli",
"jasmine-core": "^3.5.0",
"jasmine-spec-reporter": "^4.2.1",
"karma": "^4.4.1",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage-istanbul-reporter": "^2.1.1",
"karma-jasmine": "^3.1.1",
"karma-jasmine-html-reporter": "^1.5.2",
"protractor": "^5.4.3",
"ts-node": "^8.6.2",
"tslint": "~6.1.0",
"typescript": "^4.0.3"
},
"description": "Crucijuegos Salas App",
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {
"ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
},
"cordova-plugin-ionic-keyboard": {},
"cordova-plugin-local-notification": {},
"cordova-plugin-background-mode": {},
"cordova-plugin-nativestorage": {},
"cordova-android-firebase-gradle-release": {
"FIREBASE-CORE": "17.0.0",
"FIREBASE-ADS": "18.0.0",
"FIREBASE-ANALYTICS": "17.0.0",
"FIREBASE-APPINDEXING": "19.0.0",
"FIREBASE-AUTH": "18.0.0",
"FIREBASE-FIRESTORE": "20.0.0",
"FIREBASE-FUNCTIONS": "18.0.0",
"FIREBASE-MESSAGING": "19.0.0",
"FIREBASE-STORAGE": "18.0.0",
"FIREBASE-CRASH": "16.2.1",
"CRASHLYTICS": "2.10.1",
"FIREBASE-DYNAMIC-LINKS": "18.0.0",
"FIREBASE-INVITES": "17.0.0",
"FIREBASE-INAPPMESSAGING": "18.0.1",
"FIREBASE-INAPPMESSAGING-DISPLAY": "18.0.1",
"FIREBASE-ML-VISION": "21.0.0",
"FIREBASE-ML-VISION-IMAGE-LABEL-MODEL": "18.0.0",
"FIREBASE-ML-VISION-FACE-MODEL": "18.0.0",
"FIREBASE-ML-VISION-OBJECT-DETECTION-MODEL": "17.0.0",
"FIREBASE-ML-NATURAL-LANGUAGE": "20.0.0",
"FIREBASE-ML-NATURAL-LANGUAGE-LANGUAGE-ID-MODEL": "20.0.0",
"FIREBASE-ML-NATURAL-LANGUAGE-TRANSLATE-MODEL": "20.0.0",
"FIREBASE-ML-NATURAL-LANGUAGE-SMART-REPLY-MODEL": "20.0.0",
"FIREBASE-ML-MODEL-INTERPRETER": "20.0.0",
"FIREBASE-ML-VISION-AUTOML": "17.0.0",
"FIREBASE-PERF": "18.0.0",
"FIREBASE-DATABASE": "18.0.0",
"FIREBASE-CONFIG": "18.0.0"
},
"cordova-plugin-enable-multidex": {},
"cordova-plugin-inappbrowser": {},
"cordova-plugin-ble-central": {
"BLUETOOTH_USAGE_DESCRIPTION": " "
},
"cordova-plugin-bluetooth-serial": {},
"cordova-plugin-firebasex": {
"FIREBASE_ANALYTICS_COLLECTION_ENABLED": "true",
"FIREBASE_PERFORMANCE_COLLECTION_ENABLED": "true",
"FIREBASE_CRASHLYTICS_COLLECTION_ENABLED": "true"
}
},
"platforms": [
"ios",
"android"
]
}
}
Env
Mac development station
74-80-245-21:cruci-app user922954$ ionic info
Ionic:
Ionic CLI : 6.11.12 (/usr/local/lib/node_modules/#ionic/cli)
Ionic Framework : #ionic/angular 5.3.3
#angular-devkit/build-angular : 0.901.12
#angular-devkit/schematics : 9.1.12
#angular/cli : 9.1.12
#ionic/angular-toolkit : 2.3.3
Cordova:
Cordova CLI : 10.0.0
Cordova Platforms : ios 6.1.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 15 other plugins)
Utility:
cordova-res : 0.15.1
native-run (update available: 1.2.2) : 1.1.0
System:
ios-sim : 8.0.2
NodeJS : v12.16.2 (/usr/local/bin/node)
npm : 6.14.4
OS : macOS Catalina
Xcode : Xcode 12.0.1 Build version 12A7300
Linux development station (for reference)
⟩ ionic info
Ionic:
Ionic CLI : 6.11.8 (/usr/local/lib/node_modules/#ionic/cli)
Ionic Framework : #ionic/angular 5.3.3
#angular-devkit/build-angular : 0.1001.6
#angular-devkit/schematics : 10.1.6
#angular/cli : 10.1.6
#ionic/angular-toolkit : 2.3.3
Cordova:
Cordova CLI : 10.0.0
Cordova Platforms : android 9.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 16 other plugins)
Utility:
cordova-res : not installed
native-run (update available: 1.2.2) : 1.1.0
System:
Android SDK Tools : 26.1.1 (/home/praetors/Android/Sdk/)
NodeJS : v12.13.0 (/home/praetors/.nvm/versions/node/v12.13.0/bin/node)
npm : 6.12.0
OS : Linux 4.19

Related

What do I put in the content section of module exports in "tailwind.config.js"?

I can't get Tailwind to work and I think it's because my configuration file is wrong?
/** #type {import('tailwindcss').Config} */
module.exports = {
content: ["./public/index.html", "./src/**/*.{vue,js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
};
I installed Tailwind and used init:
https://imgur.com/nGWspSt
I filled in the "tailwind.config.js" like this:
tailwind.config.js
/** #type {import('tailwindcss').Config} */
module.exports = {
content: ["./src/components/DropdownVue/DropdownVue.vue"], <---INCLUDED DROPDOWN FILE
theme: {
extend: {},
},
plugins: [],
};
I created an "index.css" and imported the Tailwind modules in it like this:
src/index.css
#tailwind base;
#tailwind components; <-----INCLUDED IMPORTS
#tailwind utilities;
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Noto Serif", serif, Ariel, Helvetica, sans-serif;
background: #d7d7d7;
}
img {
width: 100%;
object-fit: contain;
}
#import url("https://fonts.googleapis.com/css2?family=Noto+Serif&display=swap");
I started the build process and got an "output.css" file
https://i.imgur.com/mOKDwuc.png
that I included in my "index.html" file like this:
public/index.html
<link href="/dist/output.css" rel="stylesheet">
At this point it should have been working but it wasn't. I realized my config file was wrong so I changed it to:
/** #type {import('tailwindcss').Config} */
module.exports = {
content: ["./public/index.html", "./src/**/*.{vue,js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
};
but it's still not working. Do I have to run the build process again because I changed the config file?
What am I doing wrong?
EDIT:
package.json
{
"name": "stripe-payment-vue3",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"#fortawesome/fontawesome-svg-core": "^6.2.1",
"#fortawesome/free-brands-svg-icons": "^6.2.1",
"#fortawesome/free-regular-svg-icons": "^6.2.1",
"#fortawesome/free-solid-svg-icons": "^6.2.1",
"#fortawesome/vue-fontawesome": "^3.0.2",
"#headlessui/vue": "^1.7.9",
"#heroicons/vue": "^2.0.14",
"core-js": "^3.8.3",
"vue": "^3.2.13",
"vue-router": "^4.1.6",
"vuex": "^4.0.2"
},
"devDependencies": {
"#babel/core": "^7.12.16",
"#babel/eslint-parser": "^7.12.16",
"#vue/cli-plugin-babel": "~5.0.0",
"#vue/cli-plugin-eslint": "~5.0.0",
"#vue/cli-service": "~5.0.0",
"autoprefixer": "^10.4.13",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3",
"postcss": "^8.4.21",
"tailwindcss": "^3.2.4"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "#babel/eslint-parser"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead",
"not ie 11"
]
}

Font not selected in Angular 10

I have created my scss project in Angular and when I try to add a font, I get an error, how do I fix the problem?
style.scss:
#import "~#angular/material/theming";
#include mat-core();
$PWP-primary: mat-palette($mat-indigo);
$PWP-accent: mat-palette($mat-pink, A200, A100, A400);
$PWP-warn: mat-palette($mat-red);
$PWP-theme: mat-light-theme($PWP-primary, $PWP-accent, $PWP-warn);
#include angular-material-theme($PWP-theme);
#import "~bootstrap/dist/css/bootstrap.css";
#import './variables.scss';
html,body {
height: 100%;
}
body {
margin: 0;
font-family: $font-vazir-bold;
direction: rtl;
}
variables.scss:
$font-vazir-bold:"Vazir";
#font-face {
font-family: Vazir;
src: url("../assets/font/vazir-font-v27.2.0/Vazir-Bold.eot");
src: url("../assets/font/vazir-font-v27.2.0/Vazir-Black.ttf") format("ttf");
}
Inside the file (angular.json) I changed the path of the style.scss file.
angular.json:
{
"$schema": "./node_modules/#angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"PWP": {
"projectType": "application",
"schematics": {
"#schematics/angular:component": {
"style": "scss"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "#angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/PWP",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/scss/styles.scss",
"src/scss/mixin.scss",
"src/scss/variables.scss",
"./node_modules/bootstrap/dist/css/bootstrap.css"
],
"scripts": [
"./node_modules/bootstrap/dist/js/bootstrap.js",
"./node_modules/bootstrap/dist/js/bootstrap.js"
]
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
},
"serve": {
"builder": "#angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "PWP:build"
},
"configurations": {
"production": {
"browserTarget": "PWP:build:production"
}
}
},
"extract-i18n": {
"builder": "#angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "PWP:build"
}
},
"test": {
"builder": "#angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/scss/styles.scss"
],
"scripts": []
}
},
"lint": {
"builder": "#angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
"e2e": {
"builder": "#angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "PWP:serve"
},
"configurations": {
"production": {
"devServerTarget": "PWP:serve:production"
}
}
}
}
}
},
"defaultProject": "PWP",
"cli": {
"analytics": "c792c032-9136-42b5-8b0a-391b6f8d84c5"
}
}
package.json:
{
"name": "pwp",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "~9.1.7",
"#angular/cdk": "^9.2.4",
"#angular/common": "~9.1.7",
"#angular/compiler": "~9.1.7",
"#angular/core": "~9.1.7",
"#angular/forms": "~9.1.7",
"#angular/material": "^9.2.4",
"#angular/platform-browser": "~9.1.7",
"#angular/platform-browser-dynamic": "~9.1.7",
"#angular/router": "~9.1.7",
"bootstrap": "^4.6.0",
"jquery": "^3.5.1",
"rxjs": "~6.5.4",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.901.6",
"#angular/cli": "~9.1.6",
"#angular/compiler-cli": "~9.1.7",
"#types/node": "^12.11.1",
"#types/jasmine": "~3.5.0",
"#types/jasminewd2": "~2.0.3",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~3.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"protractor": "~5.4.3",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~3.8.3"
}
}
Error in console:
Failed to compile.
./src/app/layout/home/home.component.scss
Module Error (from ./node_modules/postcss-loader/src/index.js):
(Emitted value instead of an instance of Error) CssSyntaxError: E:\project\PwpEnd\PWP\src\scss\variables.scss:5:4: Can't resolve '../assets/font/vazir-font-v27.2.0/Vazir-Bold.eot' in 'E:\project\PwpEnd\PWP\src\app\layout\home'
3 | #font-face {
4 | font-family: Vazir;
> 5 | src: url("../assets/font/vazir-font-v27.2.0/Vazir-Bold.eot");
| ^
6 | src: url("../assets/font/vazir-font-v27.2.0/Vazir-Black.ttf") format("ttf");
7 | }
How do I fix this problem?
enter image description here
try this
#font-face {
font-family: Vazir;
src: url("~/assets/font/vazir-font-v27.2.0/Vazir-Bold.eot");
src: url("~/assets/font/vazir-font-v27.2.0/Vazir-Black.ttf") format("ttf");
}
Ans from https://github.com/angular/angular-cli/issues/6599
I have same problem ,and it work for me
The address of the photos must be given from the root, as follows
$font-vazir-bold:"Vazir";
#font-face {
font-family: Vazir;
src: url("src/assets/font/vazir-font-v27.2.0/Vazir-Bold.eot");
src: url("src/assets/font/vazir-font-v27.2.0/Vazir-Black.ttf") format("ttf");
}

GRUNT: grunt-postcss not executing cssnano when used together with sass - if scss file long

I am using both the sass parser and gruntpostcss with cssnano on watch. cssnano` is parsing the file just fine if its a short file, but it my scss/css file gets long css file, the it is not parsing the file. Anyone knows why that is and how to fix it?
Here the package.json, Gruntfile.js and both a short-css-file.css which works and a long-css-file.css where the cssnano is not parsing it.
package.json
{
"name": "testpage",
"version": "1.0.0",
"description": "testpage grunt",
"main": "Gruntfile.js",
"dependencies": {},
"devDependencies": {
"cssnano": "^3.10.0",
"grunt": "^1.0.3",
"grunt-contrib-watch": "^1.0.0",
"grunt-postcss": "^0.8.0",
"load-grunt-tasks": "^3.5.2"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
watch: {
css: {
files: 'wp-content/themes/mytheme/assets/css/*.scss',
tasks: ['sass', 'postcss']
},
},
sass: {
options: {
sourceMap: true
},
dist: {
files: {
'wp-content/themes/mytheme/assets/css/default.css': 'wp-content/themes/mytheme/assets/css/default.scss'
}
}
},
postcss: {
options: {
map: {
inline: false, // save all sourcemaps as separate files...
sourcesContent: true,
},
processors: [
require('autoprefixer')({browsers: ['last 2 versions', 'ie 8', 'ie 9']}), // add vendor prefixes
require('cssnano')({zindex: false}) // minify the result
]
},
dist: {
files: {
'wp-content/themes/mytheme/assets/css/default.css': 'wp-content/themes/mytheme/assets/css/default.css'
}
}
},
});
require('load-grunt-tasks')(grunt);
grunt.registerTask('default', ['watch', 'sass', 'postcss']);
};
short-css-file.css
// Test
.css_nano, .css_nano + p, [class*="css_nano"], .css_nano {
/* cssnano will remove this comment */
display: flex;
font-weight: normal;
margin-top: 1rem;
margin-bottom: 2rem;
margin-left: 1.5rem;
margin-right: 2.5rem;
font-weight: normal;
padding: 1.75rem;
width: calc(50rem - (2 * 1.75rem));
}
long-css-file.css see in the jsfiddle
https://jsfiddle.net/12p3Lxcn/

Packaged font doesn't load with #font-face

In a Chrome extension, I'm injecting a <div> into a page which I want to style with a font that's packaged in the extension.
The font file isn't being downloaded, and is falling back to the serif option in the font stack.
Could it be related to me using a shadow DOM?
style.css:
#font-face {
font-family: 'Poppins-Medium';
font-style: normal;
font-weight: 500;
src: url('chrome-extension://__MSG_##extension_id__/poppins-medium.woff2') format('woff');
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
#wrapper {
font-family: 'Poppins-Medium', sans-serif;
}
content.js
var myDiv = document.createElement('div');
myDiv.setAttribute('id', 'myContainer');
myDiv.setAttribute('style', 'all: initial;');
document.body.appendChild(myDiv);
var shadow = document.querySelector('#myContainer').attachShadow({mode: 'open'});
shadow.innerHTML = `
<div id="wrapper">
<link rel="stylesheet" href="` + chrome.runtime.getURL('style.css') + `">
<div>this text should be in poppins-medium</div>
</div>
`;
manifest.json
{
"manifest_version": 2,
"name": "My Extension",
"version": "1.0",
"description": "Blah.",
"icons": {
"128": "icon128.png"
},
"browser_action": {
"default_title": "My extension"
},
"background": {
"scripts": ["background.js"]
},
"content_scripts": [
{
"run_at": "document_end",
"matches": ["<all_urls>"],
"js": ["content.js"]
}],
"web_accessible_resources": [
"style.css",
"poppins-medium.woff2"
]
}

React antdesign #media query not working

I'm working with react ant-design and I'm using #media queries for styling but it keeps throwing the error given below
#btn {
^
Media definitions require block statements after any features
in /home/osh/WebstormProjects/ant-design-kickstart/src/styles/styles.less (line 69, column 8)
# ./src/styles/styles.less 2:14-142 21:1-42:3 22:19-147
# ./src/index.js
# multi (webpack)-dev-server/client?http://localhost:8081 (webpack)/hot/dev-server.js react-hot-loader/patch ./src/index.js
Failed to compile.
I have given the related files below
------------styles.less file---------------
#media only screen and (max-width: 768px) {
#btn {
width: 50%;
margin-top: 200px;
align-self: center;
}
Button {
width: 1000%;
marginBottom: '25px'
}
Input {
align-self: center;
width: 250px;
}
h4 {
color: #5400ff;
}
.appDashCard {
background: #fff;
padding: 10%;
/*//minHeight: 280px;*/
align-content: center;
}
}
#media only screen and (min-width: 768px) {
#btn {
width: inherit;
margin-right: 30px;
margin-left: 400px;
margin-top: 30px;
}
h4 {
color: #ff2600;
}
.appDashCard {
background: #fff;
padding: 24px;
minHeight: 280px;
}
.selectBox {
width: 100%;
}
}
----------package.json----------
{
"name": "ant-design-kickstart",
"version": "1.0.0",
"description": "An opinionated starter-kit for Ant Design",
"scripts": {
"start": "webpack-dev-server --config ./webpack.dev.js --mode development",
"build": "webpack --config ./webpack.prod.js --mode production",
"precommit": "pretty-quick --staged"
},
"author": "Madusha Prasanjith",
"license": "MIT",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
"babel-plugin-import": "^1.6.7",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"css-loader": "^0.28.11",
"file-loader": "^1.1.11",
"husky": "^0.14.3",
"less": "^3.0.1",
"less-loader": "^4.1.0",
"less-vars-to-js": "^1.2.1",
"prettier": "1.11.1",
"pretty-quick": "^1.4.1",
"react-hot-loader": "^4.0.0",
"style-loader": "^0.20.3",
"url-loader": "^1.0.1",
"webpack": "^4.3.0",
"webpack-cli": "^2.0.13",
"webpack-dev-server": "^3.1.5"
},
"dependencies": {
"antd": "^3.3.3",
"axios": "^0.18.0",
"media-queries": "^1.0.5",
"moment": "^2.21.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-router-dom": "^4.2.2",
"style-loader": "^0.20.3"
}
}
-----------webpack.dev.js----------
const webpack = require("webpack");
const path = require("path");
const fs = require("fs");
const lessToJs = require("less-vars-to-js");
const themeVariables = lessToJs(
// fs.readFileSync(path.join(__dirname, "./src/styles/ant-default-vars.less"), "utf8")
fs.readFileSync(path.join(__dirname, "./src/styles/styles.less"), "utf8")
);
module.exports = {
entry: ["react-hot-loader/patch", "./src/index.js"],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ["babel-loader"]
},
{
test: /\.less$/,
use: [
{
loader: "style-loader"
},
{
loader: "css-loader",
options: {
sourceMap: true
}
},
{
loader: "less-loader",
options: {
sourceMap: true,
modifyVars: themeVariables,
javascriptEnabled: true
}
}
]
},
{
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
loader: "url-loader",
options: {
limit: 10000
}
}
]
},
resolve: {
extensions: ["*", ".js", ".jsx"]
},
output: {
path: __dirname + "/dist",
publicPath: "/",
filename: "bundle.js"
},
plugins: [new webpack.HotModuleReplacementPlugin()],
devServer: {
contentBase: "./dist",
hot: true
}
};
This often indicates a syntax error. Please take a look at 'Button'. It has a property called 'marginBottom', rename it to margin-bottom, please also add a semicolon after the statement (although that shouldn't make a difference). Also, you should rename 'Button' to 'button' and 'Input' to 'input'.

Resources