1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16const path = require('path'); 17const TerserPlugin = require('terser-webpack-plugin'); 18const webpack = require('webpack'); 19const packageInfo = require('./package.json'); 20 21module.exports = (env, argv) => { 22 const config = { 23 name: 'JSDoc formatter plugin', 24 target: 'node', 25 mode: 'none', 26 entry: './src/main.ts', 27 module: { 28 rules: [ 29 { 30 test: /\.ts$/, 31 include: path.resolve(__dirname, 'src'), 32 exclude: [/node_modules/, /test/], 33 loader: 'ts-loader', 34 options: { 35 onlyCompileBundledFiles: true, 36 }, 37 }, 38 { 39 test: /build\.json$/, 40 use: [ 41 { 42 loader: path.resolve(__dirname, 'loader/flavor.js'), 43 }, 44 ], 45 }, 46 ], 47 }, 48 resolve: { 49 extensions: ['.js', '.ts', '.json'], 50 }, 51 output: { 52 filename: 'JS_API_OPTIMIZE_PLUGIN.js', 53 path: path.resolve(__dirname, './package'), 54 }, 55 optimization: { 56 minimize: true, 57 minimizer: [new TerserPlugin({ extractComments: false })], 58 }, 59 plugins: [ 60 new webpack.BannerPlugin({ 61 banner: `version:${packageInfo.version}`, 62 raw: false, 63 entryOnly: true, 64 }), 65 ], 66 }; 67 return config; 68}; 69