π Loading local fonts via CSS returns error
See original GitHub issueπ bug report
π Configuration (.babelrc, package.json, cli command)
{
"presets": [
"env",
"vue"
]
}
{
...
"dependencies": {
"axios": "^0.17.1",
"vue": "^2.5.13",
"vue-router": "^3.0.1",
"vuex": "^3.0.1"
},
"devDependencies": {
"@storybook/addon-actions": "^3.3.10",
"@storybook/addon-links": "^3.3.10",
"@storybook/addons": "^3.3.10",
"@storybook/vue": "^3.3.10",
"babel-core": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-vue": "^2.0.0",
"css-loader": "^0.28.9",
"eslint": "^4.16.0",
"eslint-plugin-vue": "^4.2.0",
"node-sass": "^4.7.2",
"parcel-bundler": "^1.5.0",
"parcel-plugin-eslint": "^1.0.3",
"parcel-plugin-vue": "^1.5.0"
}
}
π€ Expected Behavior
I have a css file that references some local fonts:
@font-face{
font-family:example;
src:url(..\fonts\example.eot?6kxrs1);
src:url(..\fonts\example.eot?#iefix6kxrs1) format("embedded-opentype"),
url(..\fonts\example.ttf?6kxrs1) format("truetype"),
url(..\fonts\example.woff?6kxrs1) format("woff"),
url(..\fonts\example.svg?6kxrs1#example) format("svg");
font-weight:400;
font-style:normal}
I import this file in my main.js
file so it is bundled in the app.
π― Current Behavior
When trying to import the css file in my main.js
I get the following error:
Cannot read property 'add' of undefined
at JSPackager.addAsset (...\node_modules\parcel-bundler\src\packagers\JSPackager.js:56:28)
at Bundle._addDeps (...\node_modules\parcel-bundler\src\Bundle.js:146:20)
at <anonymous>
π Possible Solution
Looking at the file with the error JSPackager
I put it a validation before the this.bundleLoaders.add(mod.type);
:
if(!this.bundleLoaders){
this.bundleLoaders = new Set();
}
this.bundleLoaders.add(mod.type);
π¦ Context
π» Code Sample
π Your Environment
Software | Version(s) |
---|---|
Parcel | 1.5.0 |
Node | 8.9.3 |
npm/Yarn | 5.5.1 |
Operating System | Windows 10 |
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Problems when loading local fonts in css with font-face
I'm working with html and CSS, and I need to load a font which is in my local storage, but it gives me...
Read more >How To Load and Use Custom Fonts with CSS | DigitalOcean
The browser will sequentially attempt to load the local fonts in the font stack until it is successful. For this font stack, the...
Read more >Forums - CSS - @font-face problem
I've written a css with @font-face {font-family: taller_evolution_rev; src: url(taller_evolution_rev.otf);}. and locally it shows perfectly.
Read more >css - Custom font not loading - Webmasters Stack Exchange
I downloaded it online. I added this to my head and still no change: <link rel="stylesheet" href="shadtv.onthewifi.com:8080/fonttest/css/custom ...
Read more >How to load web fonts to avoid performance issues and speed ...
If you're using a CDN like Google Fonts, be sure that the font files you're preloading match the ones in the CSS. Fonts...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
hey @FalkoJoseph, I went to the actual code of parcel to do this. On the file
\node_modules\parcel-bundler\src\packagers\JSPackager.js
on line 56 you will see this line:So what I did to get rid of the error is put a validation before that line. Something like this:
I recommend you change the async addAsset(asset) function located in
node_modules\parcel-bundler\src\packagers\JSPackager.js: