@repodog/webpack-config
v5.0.8
Published
The Repodog webpack config module.
Downloads
338
Readme
@repodog/webpack-config
The Repodog webpack config.
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.