Coder Social home page Coder Social logo

mindspop / webpack-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from css-modules/webpack-demo

0.0 2.0 0.0 192 KB

Working demo of CSS Modules, using Webpack's css-loader in module mode

Home Page: https://css-modules.github.io/webpack-demo/

CSS 19.03% JavaScript 78.80% HTML 2.17%

webpack-demo's Introduction

Codeship Status for css-modules/webpack-demo

CSS Modules Webpack Demo

A working demo of CSS Modules, using Webpack's css-loader in module mode.

Run the example

$ npm install
$ npm start & open http://localhost:8080

npm modules required for CSS modules

In this project's package.json file you find a lot of npm modules for this demo application. Since not all of them are required for the actual CSS modules features, we've created the following list to describe their purposes.

Required modules

The following modules are the only ones really needed to get started with CSS modules:

Module Description
Webpack Webpack (obviously...)
webpack-dev-server (Optional) Supports hotloading of changed files etc while developing
style-loader and css-loader style-loader and css-loader process your CSS files. css-loader is the loader that actual makes CSS modules work

To make CSS modules work with Webpack you only have to include the modules mentioned above and add the following loader to your webpack.config.js file:

. . .
{
  test: /\.css$/,
  loader: 'style!css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]' 
}
. . .

Optional modules

The following modules control the actual CSS processing. They are not CSS modules specific and can be used with both "regular" CSS and CSS modules:

Module Description
postcss-loader Allows execution of various CSS post processor in Webpack. Required for autoprefixer-core and postcss-color-rebeccapurple
autoprefixer-core Add vendor-prefixes to your css code (according to the GitHub page it is deprecated and should be replaced by autoprefixer
postcss-color-rebeccapurple Another CSS post processor. Only needed to support rebeccapurple color in CSS
extract-text-webpack-plugin Writes the CSS code processed by Webpack into an own CSS-file and not into the generated bundle JavaScript file.

Unrelated modules

This modules are only needed for the demo application:

Module Description
babel ESx-to-ES5 compiler. Mostly needed for React code
ejs JavaScript templating language
react-to-html-webpack-plugin Webpack plug-in that renders React components
node-libs-browser Node libraries for in-browser use
gh-pages Publishes file to a gh-pages branches for GitHub pages
url-loader Webpack file handling, e.g. for images
file-loader Webpack file handling, e.g. for images
raw-loader It’s used to load raw css files (as utf8) into the demo so it can be rendered into <code>

License

MIT

webpack-demo's People

Contributors

basarat avatar lengarvey avatar markdalgleish avatar nilshartmann avatar sokra 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.