2021-03-16 12:01:13 +00:00
|
|
|
/**
|
|
|
|
* Copyright (C) 2020,2021 CismonX <admin@cismon.net>
|
|
|
|
*
|
|
|
|
* Copying and distribution of this file, with or without modification, are
|
|
|
|
* permitted in any medium without royalty, provided the copyright notice and
|
|
|
|
* this notice are preserved. This file is offered as-is, without any warranty.
|
|
|
|
*/
|
|
|
|
|
2020-11-02 07:10:13 +00:00
|
|
|
import * as path from 'path';
|
|
|
|
import * as webpack from 'webpack';
|
2021-04-02 08:36:40 +00:00
|
|
|
import { argv } from 'process';
|
2020-11-04 06:42:31 +00:00
|
|
|
import TerserPlugin from 'terser-webpack-plugin';
|
2020-11-02 07:10:13 +00:00
|
|
|
|
2021-04-02 08:36:40 +00:00
|
|
|
const isProduction = 'production' === argv[argv.indexOf('--mode') + 1];
|
|
|
|
|
2020-11-02 07:10:13 +00:00
|
|
|
const config: webpack.Configuration = {
|
|
|
|
target: 'node',
|
|
|
|
entry: './src/extension.ts',
|
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, 'out'),
|
|
|
|
filename: 'extension.js',
|
2021-05-25 04:17:36 +00:00
|
|
|
library: {
|
|
|
|
type: "commonjs2",
|
|
|
|
},
|
2020-11-02 07:10:13 +00:00
|
|
|
devtoolModuleFilenameTemplate: '../[resource-path]',
|
|
|
|
},
|
2021-04-02 08:36:40 +00:00
|
|
|
devtool: isProduction ? false : 'source-map',
|
2020-11-02 07:10:13 +00:00
|
|
|
optimization: {
|
|
|
|
concatenateModules: true,
|
2021-05-25 04:17:36 +00:00
|
|
|
minimize: isProduction,
|
2020-11-04 06:42:31 +00:00
|
|
|
minimizer: [
|
|
|
|
new TerserPlugin({
|
|
|
|
extractComments: false,
|
|
|
|
terserOptions: {
|
|
|
|
compress: {
|
|
|
|
unsafe: true,
|
2021-04-03 21:27:34 +00:00
|
|
|
unsafe_arrows: true,
|
2020-11-04 06:42:31 +00:00
|
|
|
},
|
|
|
|
format: {
|
|
|
|
comments: false,
|
|
|
|
},
|
2021-04-03 21:27:34 +00:00
|
|
|
mangle: {
|
|
|
|
module: true,
|
2021-05-25 04:17:36 +00:00
|
|
|
properties: {
|
|
|
|
regex: /^_/,
|
|
|
|
},
|
2021-04-03 21:27:34 +00:00
|
|
|
},
|
2020-11-04 06:42:31 +00:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
],
|
2020-11-02 07:10:13 +00:00
|
|
|
},
|
|
|
|
externals: {
|
|
|
|
vscode: 'commonjs vscode',
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: ['.js', '.ts'],
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'ts-loader',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export default config;
|