Giter Site home page Giter Site logo

style-loader's Introduction

style noreuse loader for webpack

Umm, sorry about the crappy name, couldn't think of a better one.

This is a fork of style-loader which does the same thing, except:

  1. doesn't support hot loaders
  2. doesn't worry about singletons, or the useable etc options
  3. doesn't reuse style tags when encountering the same module id

Why?

The why for this module is that I currently haven't figured out a better way to deal with a problem I'm having.

I'm publishing a library of react components, that want to have their own css modules bundled, but don't want to depend on an end user properly configuring webpack for me. So I'm pre-bundling components, and setting it's dependencies as webpack externals.

The trouble is, that if a prebundled component is used inside another webpack app, that basically works except module.ids get reused. That's normally not a problem as they're scoped within the component, but the module.id is shared with style-loader, who will just replace styles if it encounters styles for the same id as it had previously.

Usage

Documentation: Using loaders

Simple API

require("style!raw!./file.css");
// => add rules in file.css to document

It's recommended to combine it with the css-loader: require("style!css!./file.css").

It's also possible to add a URL instead of a CSS string:

require("style/url!file!./file.css");
// => add a <link rel="stylesheet"> to file.css to document

Options

insertAt

By default, the style-loader appends <style> elements to the end of the <head> tag of the page. This will cause CSS created by the loader to take priority over CSS already present in the document head. To insert style elements at the beginning of the head, set this query parameter to 'top', e.g. require('../style.css?insertAt=top').

Install

npm install style-noreuse-loader

License

MIT (http://www.opensource.org/licenses/mit-license.php)

style-loader's People

Contributors

sokra avatar diurnalist avatar elsbree avatar svenheden avatar latentflip avatar tgriesser avatar undozen avatar danielberndt avatar 2color avatar verticalpalette avatar denisizmaylov avatar zxcabs avatar jhnns avatar krrg avatar shama avatar sirlancelot avatar gryzzly avatar nickdima avatar erictheswift avatar simenb avatar taopaic avatar zachlysobey avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.