seek-style-guide-webpack

3.0.1 • Public • Published

Build Status npm semantic-release Commitizen friendly Styled with Prettier

seek-style-guide-webpack

Webpack decorators for integrating with the SEEK Style Guide.

Installation

$ npm install --save-dev seek-style-guide-webpack

Setup

First, decorate your server Webpack config:

const { decorateServerConfig } = require('seek-style-guide-webpack');
 
module.exports = decorateServerConfig({
  // Webpack config...
});

Then, decorate your client Webpack config:

const { decorateClientConfig } = require('seek-style-guide-webpack');
 
module.exports = decorateClientConfig({
  // Webpack config...
});

Options

CSS Output Loader { cssOutputLoader: <webpack loader> | 'style-loader' }

By default the client decorator will use style-loader to handle the styles emitted from the seek-style-guide. Alternatively, you can pass in your own loader configuration, eg.

const { decorateClientConfig } = require('seek-style-guide-webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
 
const config = {
  // Webpack config...
  plugins: [
    new MiniCssExtractPlugin(
      filename: 'style.css'
    })
  ]
};
 
module.exports = decorateClientConfig(config, {
  cssOutputLoader: MiniCssExtractPlugin.loader
});

Please note that, if your Webpack loaders aren't scoped to your local project files via the "include" option, the decorator will throw an error.

Extra includes (optional) { extraIncludePaths: Array<paths> }

If you have other external node_modules that need to be compiled in the same way as the seek-style-guide then you can pass an extra parameter to the decorators.

module.exports = decorateClientConfig(config, {
  // List of node_modules that need to be compiled by webpack
  extraIncludePaths: ['my-other-module']
});

CSS Selector Prefix (optional) { cssSelectorPrefix: string }

This selector prefix is automatically prepended to all selectors to ensure styles don't leak out into the global scope. For example, this is used for generating the standalone header & footer in the style guide.

module.exports = decorateClientConfig(config, {
  cssSelectorPrefix: '.__SSG__'
});

Contributing

Refer to CONTRIBUTING.md.

License

MIT.

/seek-style-guide-webpack/

    Package Sidebar

    Install

    npm i seek-style-guide-webpack

    Weekly Downloads

    11

    Version

    3.0.1

    License

    MIT

    Unpacked Size

    22.2 kB

    Total Files

    16

    Last publish

    Collaborators

    • markdalgleish
    • seek-oss-ci