@radic/webpacker
Webpacker
Last updated 13 days ago by radic .
MIT · Original npm · Tarball · package.json
$ cnpm install @radic/webpacker 
SYNC missed versions from official npm registry.

Webpacker

  • extends webpack-chain
  • Adds helper functions
  • Provides blocks
  • Installs missing dependencies
  • Includes many type definitions

extends webpack-chain

import Chain from 'webpack-chain'
export class Webpacker extends Chain {
    constructor(options){}
}

Adds helper functions

const wp = new Webpacker({})
wp.isDev
wp.isProd
wp.isHot
wp.isServer
wp.ensureLink(src,dest)
wp.extendConfig(config => {
    config.plugins.push(new SomePlugin())
}
wp.$on
wp.$once
wp.$off
wp.$emit
wp.beforeStart(() => console.log('starting'))
wp.beforeExit(() => console.log('starting'))

Provides blocks

const wp = new Webpacker({})
const {rules,plugins} = wp.blocks

rules.css(wp);
rules.scss(wp, {
    scss: {
        implementation: require('sass')
    }
});
rules.stylus(wp);
rules.images(wp);
rules.fonts(wp);
rules.vue(wp);
rules.pug(wp);

wp.module.rule('babel').test(/\.(js|mjs|jsx)$/).exclude.add(/node_modules/);
wp.module.rule('typescript').test(/\.(ts|tsx)$/).exclude.add(/node_modules/);

rules.babel(wp,{},'babel');

rules.cache(wp, {}, 'typescript')
rules.thread(wp, {}, 'typescript')
rules.babel(wp, {}, 'typescript');
rules.typescript(wp, {
    appendTsSuffixTo    : [ /.vue$/ ],
    configFile          : 'tsconfig.json',
    transpileOnly       : true,
    experimentalWatchApi: true,
    happyPackMode       : true,
    compilerOptions     : {
        target        : 'es5' as any,
        module        : 'esnext' as any,
        importHelpers : true,
        sourceMap     : wp.isDev,
        removeComments: wp.isProd
    }
});


plugins.friendlyErrors(wp);
plugins.bar(wp);
plugins.bundleAnalyzer(wp, {
    reportFilename: resolve(__dirname, 'bundle-analyzer.html')
});
plugins.vueLoader(wp);
plugins.define(wp, {
    DEV          : wp.isDev,
    PROD         : wp.isProd,
    HOT          : wp.isHot,
    ENV          : process.env.NODE_ENV,
    'process.env': {
        NODE_ENV: `"#{process.env.NODE_ENV}"`
    }
});

Installs missing dependencies

{
    "scripts": {
        "build": "webpack --config webpack.config.ts"
    },
    "devDependencies": {
        "@radic/webpacker": "*",
        "webpack": "*",
        "webpack-cli": "*",
        "webpack-dev-server": "*"
    }
}
import {Webpacker} from '@radic/webpacker'
const wp = new Webpacker({})

wp.blocks.rules.scss(wp)

export default wp.toConfig()
$ yarn build
- webpacker installing missing dependencies: file-loader, style-loader, sass-loader, node-sass
...

Includes many type definitions

Code completion for all blocks (plugins,helpers,etc) like file-loader, rules.scss, rules.css, plugins.bar,

Current Tags

  • 7.1.4                                ...           latest (13 days ago)

24 Versions

  • 7.1.4                                ...           13 days ago
  • 7.1.3                                ...           a month ago
  • 7.1.2                                ...           a month ago
  • 7.1.1                                ...           a month ago
  • 7.1.0                                ...           a month ago
  • 7.0.0                                ...           a month ago
  • 6.5.2                                ...           a month ago
  • 6.5.0                                ...           a month ago
  • 6.4.2                                ...           a month ago
  • 6.4.1                                ...           a month ago
  • 6.4.0                                ...           a month ago
  • 6.3.0                                ...           a month ago
  • 6.2.0                                ...           a month ago
  • 6.1.0                                ...           a month ago
  • 6.0.0                                ...           2 months ago
  • 5.1.0                                ...           2 months ago
  • 4.1.1                                ...           3 months ago
  • 4.1.0                                ...           3 months ago
  • 3.1.0                                ...           3 months ago
  • 3.0.0                                ...           3 months ago
  • 2.2.0                                ...           3 months ago
  • 2.1.0                                ...           3 months ago
  • 2.0.0                                ...           3 months ago
  • 1.0.0                                ...           3 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 576
Dependencies (17)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |