@repodog/webpack-config

5.0.8 • Public • Published

@repodog/webpack-config

The Repodog webpack config.

npm version License: MIT

Install package and peer dependency

# terminal
npm install @repodog/webpack-config webpack --save-dev

Install optional dependencies

# terminal
npm install babel-loader webpack-cli --save-dev
# or
npm install swc-loader webpack-cli --save-dev

Use package

// package.json
{
  "scripts": {
    "build": "webpack --config ./webpack.config.cjs",
  },
}

With Babel

// webpack.config.cjs
const webpackConfig = require('@repodog/webpack-config');

module.exports = {
  ...webpackConfig({ compiler: 'babel-loader' }),
  entry: './src/index.ts',
  // or
  entry: './src/index.js',

  output: {
    filename: 'index.js',
    path: path.resolve(__dirname, 'dist'),
  },
};

With SWC

// webpack.config.cjs
const swcConfig = require('@repodog/swc-config');
const webpackConfig = require('@repodog/webpack-config');

module.exports = {
  ...webpackConfig({ compiler: ['swc-loader', swcConfig.ts] }),
  entry: './src/index.ts',
  // or
  ...webpackConfig({ compiler: ['swc-loader', swcConfig.js] }),
  entry: './src/index.js',

  output: {
    filename: 'index.js',
    path: path.resolve(__dirname, 'dist'),
  },
};

Bundle tests

// webpack.config.cjs
const swcConfig = require('@repodog/swc-config');
const webpackConfig = require('@repodog/webpack-config/test.cjs');

module.exports = {
  ...webpackConfig({ compiler: 'babel-loader' }),
  // or
  ...webpackConfig({ compiler: ['swc-loader', swcConfig.ts] }),
  // or
  ...webpackConfig({ compiler: ['swc-loader', swcConfig.js] }),
};

Environment variables

DEBUG = 'true' || 'false'

Sets source-map-loader and SourceMapDevToolPlugin.

NODE_ENV = 'production' || 'development' || 'test'

When set to 'prod' or 'production', source maps are omitted.

You cam also use the environment variables outlined in @repodog/babel-config or @repodog/swc-config to control what is output.

Readme

Keywords

none

Package Sidebar

Install

npm i @repodog/webpack-config

Weekly Downloads

9

Version

5.0.8

License

MIT

Unpacked Size

6.76 kB

Total Files

5

Last publish

Collaborators

  • dylanaubrey