The Repodog webpack config.
# terminal
npm install @repodog/webpack-config webpack --save-dev
# terminal
npm install babel-loader webpack-cli --save-dev
# or
npm install swc-loader webpack-cli --save-dev
// package.json
{
"scripts": {
"build": "webpack --config ./webpack.config.cjs",
},
}
// 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'),
},
};
// 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'),
},
};
// 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] }),
};
Sets source-map-loader
and SourceMapDevToolPlugin
.
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.