12.0.0 • Published 3 years ago

pobpack-node v12.0.0

Weekly downloads
5
License
ISC
Repository
github
Last release
3 years ago

#features)

Screenshot

hello-example

Features

  • Start without config
  • Hot Module Reload
  • Human readable errors
  • You can override everything in the webpack config

Install

npm install --save pobpack-node

Usage

package.json

{
  "scripts": {
    "build": "pobpack-node build",
    "start": "pobpack-node"
  }
}
npm run start

Configuration Options

You can create a file named createWebpackConfig.js next to package.json:

module.exports = function (config, options) {
  return config({
    ...options,
    babel: {}, // babel config (see below)
    jsLoaders: {}, // add more webpack loaders to js/jsx (see below)
    moduleRules: [], // add more webpack rules
    prependPlugins: [], // prepend plugins
    plugins: [], // append plugins
    paths: { src: 'src', build: 'build' },
  });
};

Hot Reload

You should read webpack documentation about HMR

You can activate accept hot-reload by default with webpack-module-hot-accept

npm install --save-dev webpack-module-hot-accept

createWebpackConfig.js

module.exports = function (config, options) {
  return config(
    Object.assign({}, options, {
      jsLoaders: ['webpack-module-hot-accept'],
    }),
  );
};

Configuration examples

module.exports = function (config, options) {
  return config(Object.assign({}, options, {}));
};

Add a webpack plugin

module.exports = function (config, options) {
  return config(
    Object.assign({}, options, {
      plugins: [new WebPackPlugin()],
    }),
  );
};

You can also do:

module.exports = function (config, options) {
  config = config(options);
  config.plugins.push(new WebPackPlugin());
  return config;
};

Add a babel plugin

const babelPlugin = require('babel-plugin-example');

module.exports = function (config, options) {
  return config(
    Object.assign({}, options, {
      babel: {
        plugins: [babelPlugin],
      },
    }),
  );
};

Override babel preset

const babelPlugin = require('babel-plugin-example');

module.exports = function (config, options) {
  return config(
    Object.assign({}, options, {
      babel: {
        presets: ['pobpack/babel', 'stage-1'],
      },
    }),
  );
};

Add webpack loaders

pobpack handle json and js/jsx files

const babelPlugin = require('babel-plugin-example');

module.exports = function (config, options) {
  return config(
    Object.assign({}, options, {
      loaders: [
        // add your loaders
      ],
    }),
  );
};

Add js/jsx loaders

const babelPlugin = require('babel-plugin-example');

module.exports = function (config, options) {
  return config(
    Object.assign({}, options, {
      jsLoaders: [
        // add your loaders
      ],
    }),
  );
};

Alternatives

12.0.0

3 years ago

10.0.0

3 years ago

11.0.0

3 years ago

11.0.1

3 years ago

9.0.0

4 years ago

8.1.1

4 years ago

8.1.0

4 years ago

8.0.3

4 years ago

8.0.1

4 years ago

8.0.0

4 years ago

8.0.2

4 years ago

7.7.3

5 years ago

7.7.2

5 years ago

7.7.1

5 years ago

7.7.0

5 years ago

7.6.3

5 years ago

7.6.2

5 years ago

7.6.1

5 years ago

7.6.0

5 years ago

7.5.0

5 years ago

7.4.1

5 years ago

7.4.0

5 years ago

7.3.1

5 years ago

7.3.0

5 years ago

7.2.3

5 years ago

7.2.2

5 years ago

7.2.1

5 years ago

7.2.0

5 years ago

7.1.0

5 years ago

7.0.1

5 years ago

7.0.0

5 years ago

6.2.0

5 years ago

6.1.0

6 years ago

6.0.0

6 years ago

5.0.6

6 years ago

5.0.5

6 years ago

5.0.4

6 years ago

5.0.3

6 years ago

5.0.2

6 years ago

5.0.1

6 years ago

5.0.0

6 years ago

4.1.4

6 years ago

4.1.3

6 years ago

4.1.2

6 years ago

4.1.1

6 years ago

4.1.0

6 years ago

4.0.0

6 years ago

3.2.1

6 years ago

3.2.0

6 years ago

3.1.3

6 years ago

3.1.2

7 years ago

3.1.1

7 years ago

3.1.0

7 years ago

3.0.3

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.1.0

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.8.1

7 years ago

0.7.0

7 years ago

0.6.0

7 years ago

0.5.0

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago