DEV Community

Aaron Eastall
Aaron Eastall

Posted on

sass-loader `~` imports with webpack

Discovered this today, when compiling sass files from packages installed with npm. Handy shortcut instead of specifying directly the pathing.

From the doco: https://webpack.js.org/loaders/sass-loader/

The sass-loader uses Sass's custom importer feature to pass all queries to the Webpack resolving engine. Thus you can import your Sass modules from node_modules. Just prepend them with a ~ to tell Webpack that this is not a relative import:

@import '~bootstrap';

Top comments (0)