core icon indicating copy to clipboard operation
core copied to clipboard

Documentation format of each easy-webpack module

Open Holi0317 opened this issue 9 years ago • 1 comments

Currently, all easy-webpack modules do not have any documentation. This require users to check source code for each module's function and how to use it. I would like to help with documentation and improve easy-webpack.

Before starting, what should be included in documentation? I can think of the followings.

  • Short description on what the package can do
  • Installation, sample usage and output config
  • Description on each options
  • Related tutorials
  • Tips (if any)

@niieani

Take config-css as example. Here is the sample documentation.

@easy-webpack/config-css

Include and inject css using css-loader and style-loader

Installation

npm install --save-dev @easy-webpack/config-css

easy-webpack is also required.

Usage

// webpack.config.js
const generateConfig = require('@easy-webpack/core').generateConfig;

const baseConfig = { ... }; // project-specific config like the entry file(s)

module.exports = generateConfig(
  baseConfig,

  require('@easy-webpack/config-css')
    ({ filename: 'styles.css', allChunks: true, sourceMap: false })
);

/*
module.exports will be the following:
{
  ...
}
*/

On any JavaScript module, simply import your css file and it will be injected into the DOM globally.

// app.js
require('./style.css')  // CommonJS style import
import './style.css'    // ES Module import

Options

filename

Type: String Default: [name].css

Filename of the extracted css file. Only be used if extractText is not false or undefined.

allChunks

(Other options)

Related tutorials

Tips

Add PostCSS to pipeline

PostCSS is a set of plugins that can transform your CSS.

To add PostCSS install postcss-loader first.

Then, (etc...)

Holi0317 avatar Jan 12 '17 14:01 Holi0317

Sounds great! If you're willing to contribute the README files for individual repositories, I'll merge them all ASAP!

Thanks.

niieani avatar Jan 15 '17 08:01 niieani