GithubHelp home page GithubHelp logo

olxbrasil / webpack-blocks-happypack Goto Github PK

View Code? Open in Web Editor NEW

This project forked from diegohaz/webpack-blocks-happypack

0.0 2.0 0.0 107 KB

A webpack block that adds happypack support to your webpack config

License: MIT License

JavaScript 100.00%

webpack-blocks-happypack's Introduction

webpack-blocks-happypack

Generated with nod NPM version Build Status Coverage Status

A webpack block that adds happypack support to your webpack config.

This package is based on the PR by @fenos on the official webpack-blocks repository.

Install

$ npm install --save-dev webpack-blocks-happypack

Usage

Basic

const { createConfig } = require('@webpack-blocks/webpack2')
const babel = require('@webpack-blocks/babel6')
const cssModules = require('@webpack-blocks/css-modules')
const extractText = require('@webpack-blocks/extract-text2')
const happypack = require('webpack-blocks-happypack')

const config = createConfig([
  cssModules(),
  happypack([
    // these will be happypack'd
    extractText(),
    babel(),
  ]),
])

Configuration

const config = createConfig([
  happypack([
    babel(),
  ], {
    // default options
    loaders: ['babel-loader', 'css-loader'], // allowed loaders
    cache: !process.env.DISABLE_HAPPY_CACHE,
    cacheContext: {
      env: process.env.NODE_ENV,
      refresh: process.env.REFRESH_HAPPY_CACHE ? Math.random() : 0,
      // ... add or override happypack cacheContext options
    },
    // ... add or override happypack options
  }),
])

Environment variables

$ DISABLE_HAPPY=true webpack # turns happypack off and run webpack
$ DISABLE_HAPPY_CACHE=true webpack # turns happypack cache off and run webpack
$ REFRESH_HAPPY_CACHE=true webpack # refreshes happypack cache and run webpack

How it does

This webpack block adds HappyPack plugins with proper IDs and replaces loaders by happypack/loader?id=${id}.

API

happypack

Parameters

  • blocks Array<WebpackBlock>
  • $1 any (optional, default {})
    • $1.loaders (optional, default ['babel-loader','css-loader'])
    • $1.happypackOptions ...any

Returns Array<Block>

Loader

Type: string

Rule

Type: {test: RegExp, loader: (Loader | Array<Loader>)?, loaders: (Loader | Array<Loader>)?, use: (Loader | Array<Loader>)?}

Properties

Block

Type: {plugins: Array<any>?, module: {loaders: Array<Rule>?, rules: Array<Rule>?}}

Properties

BlockOptions

Type: {loaders: Array<string>?, refresh: boolean?, cache: any?, cacheContext: {}?}

Properties

WebpackBlock

Type: function (): Block

Other useful webpack blocks

License

MIT © Diego Haz

webpack-blocks-happypack's People

Contributors

diegohaz avatar greenkeeper[bot] 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.