-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
48 lines (44 loc) · 1.42 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const TerserJSPlugin = require('terser-webpack-plugin');
const nodeExternals = require('webpack-node-externals');
const rules = require('./dist/rulesconfig-wp');
const {CycloneDxWebpackPlugin} = require('@cyclonedx/webpack-plugin');
/** @type {import('@cyclonedx/webpack-plugin').CycloneDxWebpackPluginOptions} */
const cycloneDxWebpackPluginOptions = {
specVersion: '1.4',
rootComponentType: 'library',
outputLocation: './bom'
};
const productionPlugins =
process.env.WEBPACK_MODE === 'production' ?
[new TerserJSPlugin({}), new CssMinimizerPlugin()] :
[];
const ComponentsConfig = {
entry: './dist/index.js',
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'dist/lib'),
libraryTarget: 'commonjs',
publicPath: '/'
},
mode: 'development',
devtool: 'source-map',
externals: [nodeExternals()],
resolve: {
extensions: ['.js', '.json', '.jsx', '.scss']
},
module: {
rules
},
plugins: [
...productionPlugins,
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css'
}),
new CycloneDxWebpackPlugin(cycloneDxWebpackPluginOptions)
]
};
module.exports = [ComponentsConfig];