New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

webpack-css-loaders

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-css-loaders

Install all necessary webpack css loaders ready to use

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Installation

This one package will let you use css loaders in your projects. Use npm install webpack-css-loaders instead of installing all css-loaders separately.

The following dependencies will be installed:

Package name
css-loader
style-loader
url-loader
file-loader
webpack

Configuration

Require the path module in your webpack.config.js file
var path = require('path');

module.exports = {
  //webpack config
}
Set output folders for images and fonts used in css

The example of folders arrangement:

	output:{
		path: path.join(__dirname,'public/assets/'),
        publicPath:'assets/'
	},
Set loaders

Add the loaders to your webpack.config.js file:

module: {
  rules: [
    {
      test: /\.(jpe?g|png|gif)$/i,   //to support eg. background-image property
      loader:"file-loader",
      query:{
        name:'[name].[ext]',
        outputPath:'images/'
        //the images will be emmited to public/assets/images/ folder
        //the images will be put in the DOM <style> tag as eg. background: url(assets/images/image.png);
      }
    },
    {
      test: /\.(woff(2)?|ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,    //to support @font-face rule
      loader: "url-loader",
      query:{
        limit:'10000',
        name:'[name].[ext]',
        outputPath:'fonts/'
        //the fonts will be emmited to public/assets/fonts/ folder
        //the fonts will be put in the DOM <style> tag as eg. @font-face{ src:url(assets/fonts/font.ttf); } 
      }
    },
    {
      test: /\.css$/,
      loaders: ["style-loader","css-loader"]
    }
  ]
}

Usage

To put the CSS into the DOM use:

require("some_styles.css");

or set the entry property in the webpack.config.js file:

entry: [
    "some_styles.css",
    "your-entry-point.js"
]
  • style-loader
  • css-loader
  • url-loader
  • file-loader

See also

Keywords

webpack

FAQs

Package last updated on 13 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts