1.0.0 • Published 7 years ago

unb-questionario v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

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:

ModuleDescription
WebpackWebpack (obviously...)
webpack-dev-server(Optional) Supports hotloading of changed files etc while developing
style-loader and css-loaderstyle-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:

ModuleDescription
postcss-loaderAllows execution of various CSS post processor in Webpack. Required for autoprefixer-core and postcss-color-rebeccapurple
autoprefixer-coreAdd vendor-prefixes to your css code (according to the GitHub page it is deprecated and should be replaced by autoprefixer
postcss-color-rebeccapurpleAnother CSS post processor. Only needed to support rebeccapurple color in CSS
extract-text-webpack-pluginWrites 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:

ModuleDescription
babelESx-to-ES5 compiler. Mostly needed for React code
ejsJavaScript templating language
react-to-html-webpack-pluginWebpack plug-in that renders React components
node-libs-browserNode libraries for in-browser use
gh-pagesPublishes file to a gh-pages branches for GitHub pages
url-loaderWebpack file handling, e.g. for images
file-loaderWebpack file handling, e.g. for images
raw-loaderIt’s used to load raw css files (as utf8) into the demo so it can be rendered into <code>

License

MIT

1.0.0

7 years ago