Importing CSS from node_modules #1367

Closed
opened 2025-08-09 17:19:52 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @nklt on 9/21/2016

Will the project include capability to import css files from npm modules.
There are a list of npm projects for UI controls that is bundled in npm modules, and will be very useful to be able to import the css files from the node_modules location, inside the typescript definition files.

for example

@Component({
selector: 'counter',
styleUrls: ['/node_modules/company-a/component-b/main.css'], // load the button theme
template: require('./counter.component.html')
})

Currently this does not work (whether we specify ./../ or any relative path to help the TSC find the file location. In the webpack.config.js module, current it only looks at ClientApp folder. We tried to add node_modules path in webpack.config.js but the webpack engine does not like compoents with "@" sign on the module name, such as @angular/xyz.

*Originally created by @nklt on 9/21/2016* Will the project include capability to import css files from npm modules. There are a list of npm projects for UI controls that is bundled in npm modules, and will be very useful to be able to import the css files from the node_modules location, inside the typescript definition files. for example @Component({ selector: 'counter', styleUrls: ['/node_modules/company-a/component-b/main.css'], // load the button theme template: require('./counter.component.html') }) Currently this does not work (whether we specify ./../ or any relative path to help the TSC find the file location. In the webpack.config.js module, current it only looks at ClientApp folder. We tried to add node_modules path in webpack.config.js but the webpack engine does not like compoents with "@" sign on the module name, such as @angular/xyz.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#1367
No description provided.