6.46.8 • Published 4 days ago

@gasket/plugin-webpack v6.46.8

Weekly downloads
95
License
MIT
Repository
github
Last release
4 days ago

@gasket/plugin-webpack

Adds Webpack support to your application.

Installation

New apps

gasket create <app-name> --plugins @gasket/plugin-webpack

Existing apps

npm i @gasket/plugin-webpack webpack

Modify plugins section of your gasket.config.js:

module.exports = {
  plugins: [
    add: [
+      '@gasket/plugin-webpack'
    ]
  ]
}

Configuration

The webpack plugin is configured using the gasket.config.js file.

First, add it to the plugins section of your gasket.config.js:

module.exports = {
  plugins: {
    add: ['@gasket/webpack']
  }
}

You can optionally define a specific user webpack config using the webpack property. This configuration will be smartly merged into the application's current webpack configuration.

module.exports = {
  plugins: {
    add: ['@gasket/webpack']
  },
  webpack: {
    performance: {
      maxAssetSize: 20000
    }
  }
};

This config can be further modified by interacting with the webpack lifecycle.

API

webpack exposes an init function called initWebpack.

initWebpack

Use this to initialize the webpack lifecycles in a consuming plugin.

const { initWebpack } = require('@gasket/plugin-webpack');

/**
* Creates the webpack config
* @param  {Gasket} gasket The Gasket API
* @param {Object} webpackConfig Initial webpack config
* @param {Object} data Additional info
* @returns {Object} Final webpack config
*/
const config = initWebpack(gasket, webpackConfig, data);

Lifecycles

webpackChain

Executed before the webpack lifecycle, allows you to easily create the initial webpack configuration using a chaining syntax that is provided by the webpack-chain library. The resulting configuration is then merged with:

  • WebPack configuration that is specified in the gasket.config.js as webpack object.

The result of this will be passed into the webpack hook as base configuration.

webpack

Executed after webpack-chain lifecycle. It receives the full webpack config as first argument. It can be used to add additional configurations to webpack.

const { DefinePlugin } = require('webpack');

/**
 * @param {Gasket} gasket The gasket API
 * @param {Object} config webpack configuration
 * @return {Object} resolved webpack configuration
 */
function webpackHook(gasket, config) {
  config.plugins.push(
    new DefinePlugin({
      MEANING_OF_LIFE: 42
    })
  );

  return config;
}

License

MIT

7.0.0-next.21

4 days ago

7.0.0-next.9

9 days ago

7.0.0-next.10

9 days ago

7.0.0-next.7

9 days ago

7.0.0-next.11

9 days ago

7.0.0-next.8

9 days ago

7.0.0-next.12

9 days ago

7.0.0-next.13

9 days ago

7.0.0-next.6

9 days ago

7.0.0-next.20

9 days ago

7.0.0-next.5

10 days ago

6.46.8

11 days ago

7.0.0-next.4

12 days ago

7.0.0-next.3

16 days ago

7.0.0-next.2

23 days ago

7.0.0-next.1

24 days ago

7.0.0-next.0

24 days ago

7.0.0-cli.7

2 months ago

7.0.0-cli.6

2 months ago

6.46.1-cli.0

2 months ago

7.0.0-cli.5

2 months ago

7.0.0-cli.4

2 months ago

7.0.0-cli.1

2 months ago

7.0.0-cli.0

2 months ago

7.0.0-cli.3

2 months ago

7.0.0-cli.2

2 months ago

6.46.3-cli.0

2 months ago

6.46.2

2 months ago

7.0.0-canary.1

2 months ago

6.46.2-esm.0

3 months ago

6.45.2

3 months ago

6.45.0

4 months ago

6.43.0

7 months ago

6.39.3

11 months ago

6.39.0

12 months ago

6.38.8

12 months ago

6.38.5

1 year ago

6.38.1

1 year ago

6.36.1

1 year ago

6.38.0

1 year ago

6.34.6

2 years ago

6.36.0

1 year ago

6.34.3

2 years ago

6.34.4

2 years ago

6.34.2

2 years ago

6.26.1

2 years ago

6.21.0

2 years ago

6.24.2

2 years ago

6.24.0

2 years ago

6.20.4

2 years ago

6.20.3

2 years ago

6.20.2

2 years ago

6.20.1

2 years ago

6.19.0

2 years ago

6.17.0

2 years ago

6.15.2

2 years ago

6.10.1

2 years ago

6.10.0

2 years ago

6.14.0

2 years ago

6.8.2

2 years ago

6.6.0

3 years ago

6.4.0

3 years ago

6.0.12

3 years ago

6.0.3

3 years ago

6.0.0

3 years ago

6.0.0-canary.13

3 years ago

6.0.0-canary.9

3 years ago

6.0.0-canary.6

3 years ago

6.0.0-canary.0

4 years ago

5.6.0

4 years ago

5.3.1

4 years ago

5.1.3

4 years ago

5.0.2

4 years ago

5.0.1

4 years ago

5.0.0

4 years ago

5.0.0-canary.4

4 years ago

5.0.0-canary.3

4 years ago

5.0.0-canary.2

4 years ago

5.0.0-canary.1

4 years ago

5.0.0-canary.0

4 years ago