SwitchUp SwitchUp Ranked Best Coding Bootcamps 2025

How to import some css files as global in js while the rest are imported as local

Altcademy Team wrote on 7 February 2018

I use webpack to handle my css files. I configured my css and sass loaders to import files as modules. But sometimes I want to import some files as global. What's the best way to do this?

You can do it like this in your js files. From https://github.com/css-modules/css-modules/pull/65

// import in default mode (using CSS Modules) import styles from 'styles.css'; // This imported styles globally without running through CSS Modules import '!style!css!styles.css'; // This imported styles globally using SCSS for example import '!style!css!sass!styles.scss';
The idea is: if we need to import something differently, we explicitly declared its loaders (and options maybe) when we import

Trusted by

Students and instructors from world-class organizations

Imperial College London
Carnegie Mellon University
City University of Hong Kong
Hack Reactor
Cisco Meraki
University of Oxford
Swift
Bazaarvoice
Waterloo
Uber
AtlanTech
Tumblr
Boston College
Bombardier Aerospace
University of St. Andrews
New York University
Minerva Schools at KGI
Merrill Lynch
Riot Games
JP Morgan
Morgan Stanley
Advanced Placement®
Google
KPMG
The University of Hong Kong
University of Toronto
SCMP
Moat
Zynga
Hello Toby
Deloitte
Goldman Sachs
Yahoo
HSBC
General Assembly
Tesla
McGill University
Microsoft

Join the upcoming Cohort #97

Enroll for January 6th, 2025