7.7.0 • Published 4 years ago

@radic/webpacker v7.7.0

Weekly downloads
34
License
MIT
Repository
-
Last release
4 years ago

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,

7.7.0

4 years ago

7.6.1

4 years ago

7.6.0

4 years ago

7.5.1

4 years ago

7.5.0

4 years ago

7.4.0

4 years ago

7.3.0

4 years ago

7.2.1

4 years ago

7.2.0

4 years ago

7.1.4

5 years ago

7.1.3

5 years ago

7.1.2

5 years ago

7.1.1

5 years ago

7.1.0

5 years ago

7.0.0

5 years ago

6.6.0

5 years ago

6.5.2

5 years ago

6.5.0

5 years ago

6.4.2

5 years ago

6.4.1

5 years ago

6.4.0

5 years ago

6.3.0

5 years ago

6.2.0

5 years ago

6.1.0

5 years ago

6.0.0

5 years ago

5.1.0

5 years ago

4.1.1

5 years ago

4.1.0

5 years ago

3.1.0

5 years ago

3.0.0

5 years ago

2.2.0

5 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.0.0

5 years ago