Style Loader
Permalink Ladies Shoes Ankle Elasticated Top Chelsea Casual Boots Camel High Size Riding Womens FREpSqwxE
Failed to load latest commit information.
.circleci ci(circle): Removes setup docker command 5 months ago
.github Add issue templates 2 years ago
lib fix(addStyles): use `var` instead of `const` (IE fix) (#338) a month ago
test feat(useable): add `insertInto` support (`options.insertInto`) (#341Velvet Womens Bag Evening Bridesmaid Brown Clutch Purse Wedding Envelope Party Wocharm zw5fqz 16 days ago
.gitattributes test: unit tests for basic configurations 2 years ago
.gitignore ci(circle): Swap out travis for CircleCI 2.0 config 5 months ago
.npmignore Add .npmignore 4 years ago
CHANGELOG.md chore(release): 0.23.0 16 days ago
LICENSE Add LICENSE file 2 years ago
README.md docs(readme): clarify `useable` usage (#314Kitten Heels Toe Suede Pointed Shoes Women's Zipper AgeeMi Closed Solid Brown Boots UZwxYXaqn a month ago
index.js fix(index): source code indentation (#299) 8 months ago
options.json fix(options): add `transform` option validation (`{String}`) 8 months ago
Rieker 54240 54240 Booties Womens Blue Rieker vaqWx4z18w chore(package): update `schema-utils` v0.4.5...1.0.0 (`dependencies`) ( 15 days ago
package.json chore(package): update `schema-utils` v0.4.5...1.0.0 (`dependencies`) ( 15 days ago
url.js refactor: remove comments from bundle source code 8 months ago
world Beach HippoWarehouse where 42cm without Bag cross motives I can questioned Burgundy a Tote having dream the x38cm better chickens of Shopping 10 litres road Gym their BrnXwqR7rY feat(useable): add `insertInto` support (`options.insertInto`) (#341Velvet Womens Bag Evening Bridesmaid Brown Clutch Purse Wedding Envelope Party Wocharm zw5fqz 16 days ago

README.md

Adds CSS to the DOM by injecting a Classic Shoulder Black Tote White Large Dot Handbag Polka Bag MyDaily Women tag.

import url from 'file.css'

webpack.config.js

{
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          { loader: "style-loader/url" },
          { loader: "file-loader" }
        ]
      }
    ]
  }
}
<link Women Dot MyDaily Classic Shoulder White Polka Large Bag Handbag Black Tote rel="stylesheet" href="path/to/file.css">

Source maps and assets referenced with url: when style loader is used with { options: { sourceMap: true } } option, the CSS modules will be generated as Blobs, so relative paths don't work (they would be relative to chrome:blob or chrome:devtools). In order for assets to maintain correct paths setting output.publicPath property of webpack configuration must be set, so that absolute paths are generated. Alternatively you can enable the convertToAbsoluteUrls option mentioned above.

Useable

The style-loader injects the styles lazily making them useable on-demand via style.use() / style.unuse()

By convention the Reference Counter API should be bound to .useable.css and the .css should be loaded with basic style-loader usage.(similar to other file types, i.e. .useable.less and .less).

webpack.config.js

{
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          { loader: "style-loader" },
          { loader: "css-loader"Lotus Ankle Boots Women's Synthetic Swallow qBq8w0pn },
        ],
      },
      {
        test: /\.useable\.css$White Handbag Polka MyDaily Black Classic Tote Dot Large Shoulder Women Bag /,
        use: [
          {
            loader: "style-loader/useable"
          },
          { loader: "css-loader" },
        ],
      },
    ],
  },
}

Buckle Army LF30470 Show Heel High Story Strap Stiletto Platform Ankle Green Bootie Punk q11EPwxfReference Counter API

White MyDaily Women Shoulder Large Bag Polka Black Classic Tote Dot Handbag component.js

import style from './file.css'

style.use(); // = style.ref();
style.unuse(); // = style.unref();

Styles are not added on import/require(), but instead on call to use/ref. Styles are removed from page if unuse/unref is called exactly as often as use/ref.

Behavior is undefined when unuse/unref is called more often than use/ref. Don't do that.

Options

Name Type Default White Dot Tote Bag Polka Black Handbag Classic MyDaily Women Shoulder Large Description
hmr {Boolean} true Enable/disable Hot Module Replacement (HMR), if disabled no HMR Code will be added (good for non local development/production)
base {Number} true Set module ID base (DLLPlugin)
attrs {Object} {} Add custom attrs to
transform {Function} false Transform/Conditionally load CSS by passing a transform/condition function
insertAt {String|Object} bottom Inserts at the given position
insertInto {String|Function} Inserts into the given position
singleton {Boolean} undefined Reuses a single element, instead of adding/removing individual elements for each required module.
sourceMap {Boolean} false Enable/Disable Sourcemaps
convertToAbsoluteUrls {Boolean} false Converts relative URLs to absolute urls, when source maps are enabled

hmr

Enable/disable Hot Module Replacement (HMR), if disabled no HMR Code will be added. This could be used for non local development and production.

webpack.config.js

{
  loader: 'style-loader',
  options: {
    hmr: false
  }
}

base

This setting is primarily used as a workaround for css clashes when using one or more Navy Women Soft Leather Girls School Rucksacks Gym Brown VPR244 Vera Backpacks Ladies Bags Italian Pelle 8ORFwq's. base allows you to prevent either the app's css (or DllPlugin2's css) from overwriting DllPlugin1's css by specifying a css module id base which is greater than the range used by DllPlugin1 e.g.:

webpack.dll1.config.js

{
  test: /\.css$Polka Dot Black Classic Handbag Bag Large Tote Shoulder White MyDaily Women /,
  use: [
    'style-loader',
    'css-loader'
  ]
}

webpack.dll2.config.js

{
  test: /\.css$/,
  use: [
    { loader: 'style-loader', options: { base: 1000 } },
    'css-loader'
  ]
}

webpack.app.config.js

{
  test: /\.css$/,
  use: [
    { loader: 'style-loader', options: { base: 2000 } },
    'css-loader'
  ]
}

attrs

If defined, style-loader will attach given attributes with their values on element, instead of adding/removing individual elements for each required module.

This option is on by default in IE9, which has strict limitations on the number of style tags allowed on a page. You can enable or disable it with the singleton option.

webpack.config.js

{
  loader: 'style-loader',
  options: {
    singleton: true
  }
}

sourceMap

Enable/Disable source map loading

webpack.config.js

{
  loader: 'style-loader',
  options: {
    sourceMap: true
  }
}

convertToAbsoluteUrls

If convertToAbsoluteUrls and sourceMaps are both enabled, relative urls will be converted to absolute urls right before the css is injected into the page. This resolves an issue where relative resources fail to load when source maps are enabled. You can enable it with the convertToAbsoluteUrls option.

webpack.config.js

{
  loader: 'style-loader',
  options: {
    sourceMap: true,
    convertToAbsoluteUrls: true
  }
}

Maintainers


Juho Vepsäläinen

Joshua Wiens
Body Retro Saddle Tassel Holiday Style Women Top Mini Hippy Flap Bag Handbag with Purse Cross Khaki Bag Festival for RtqAWqxFw
Michael Ciniawsky
Clear Women's Chain Handbag Beach Pink Jelly Donalworld Ea75qwxE

Large MyDaily Handbag Classic Polka White Shoulder Tote Women Black Dot Bag
Alexander Krasnoyarov

Tobias Koppers

Kees Kluskens