Skip to content

A loader for webpack that concatenates multiple modules into a single module.

License

Notifications You must be signed in to change notification settings

minodisk/multiple-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

multiple-loader CircleCI

A loader for webpack that concatenates multiple modules into a single module.

Installation

npm install -D multiple-loader

Usage

webpack.config.js:

var multiple = require("multiple-loader")

module.exports = {
  module: {
    loaders: [
      {
        test: /\.css$/,
        loader: multiple(
          [
            'css-inline'
          ],
          [
            'style',
            'css?modules'
          ]
        )
      }
    ]
  }
}

example.css:

.foo {
  background-color: #FF0000;
}

exmaple.js:

const [ styles, classes ] = require('./example.css')

console.log(styles)   // -> {
                      //   foo: {
                      //     backgroundColor: '#FF0000'
                      //   }
                      // }

console.log(classes)  // -> {
                      //   foo: '_2lYda0XDAEUVhH-nj3Cjlo'
                      // }

class MyComponent extends React.Component {
  render () => {
    return (
      <div>
        <div style={styles.foo}></div>
        <div className={classes.foo}></div>
      </div>
    )
  }
}

About

A loader for webpack that concatenates multiple modules into a single module.

Resources

License

Stars

Watchers

Forks

Packages

No packages published