Reputation: 2527
Im trying to import a package called cssdom in angular:
like this:
import * as CssDom from "cssdom";
But I'm getting the following error:
when I try to create a new instance of CssDom like this:
const css = '.container { background-color: white; }';
const cssdom = new CssDom(css)
I tried this way also:
import {CssDom} from 'cssdom'
Or is there a way to import these third party packages in to angular?
In vue-js this is very easy. As you can import simply. But with typescript/angular this seems hard.!
Upvotes: 0
Views: 755
Reputation: 24314
First install cssdom (if not done yet):
$ npm i cssdom
Solution 1 :
Add the script to angular.json
"scripts": [
...
"../node_modules/cssdom/cssdom.js"
...
],
Next use cssdom like this:
declare const CssDom:any;
...
const css = '.container { background-color: white; }';
const cssdom = new CssDom(css)
Solution 2 :
declare var CssDom:any;
import "cssdom";
Upvotes: 1