mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
92 lines
2.3 KiB
JavaScript
92 lines
2.3 KiB
JavaScript
'use strict';
|
|
|
|
const path = require('path');
|
|
|
|
const nodeExternals = require('webpack-node-externals');
|
|
const webpack = require('webpack');
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
const ForkTsCheckerNotifierWebpackPlugin = require('fork-ts-checker-notifier-webpack-plugin');
|
|
const ESLintPlugin = require('eslint-webpack-plugin');
|
|
const packageJson = require('pjson');
|
|
|
|
const WebpackUtils = require('./utils/WebpackUtils').WebpackUtils;
|
|
|
|
module.exports = {
|
|
context: path.resolve(__dirname, '..'),
|
|
devtool: 'source-map',
|
|
entry: {
|
|
'index': './index.ts',
|
|
'index.cli': './index.cli.ts'
|
|
},
|
|
target: 'node',
|
|
externals: [nodeExternals()],
|
|
module: {
|
|
exprContextCritical: false,
|
|
rules: [
|
|
{
|
|
test: /\.ts$/,
|
|
loader: 'ts-loader',
|
|
options: {
|
|
transpileOnly: true
|
|
}
|
|
}
|
|
]
|
|
},
|
|
resolve: {
|
|
extensions: ['.ts']
|
|
},
|
|
cache: {
|
|
type: 'filesystem',
|
|
buildDependencies: {
|
|
config: [
|
|
__filename
|
|
]
|
|
}
|
|
},
|
|
plugins: [
|
|
new webpack.BannerPlugin(
|
|
{
|
|
banner: WebpackUtils.getBannerText(
|
|
WebpackUtils.getLicenseText()
|
|
),
|
|
raw: true,
|
|
entryOnly: false
|
|
}
|
|
),
|
|
new webpack.EnvironmentPlugin({
|
|
VERSION: packageJson.version,
|
|
BUILD_TIMESTAMP: Date.now()
|
|
}),
|
|
new ForkTsCheckerWebpackPlugin({
|
|
typescript: {
|
|
configFile: 'src/tsconfig.node.json'
|
|
}
|
|
}),
|
|
new ESLintPlugin({
|
|
files: 'src/**/*.ts'
|
|
}),
|
|
new ForkTsCheckerNotifierWebpackPlugin({
|
|
skipFirstNotification: true
|
|
})
|
|
],
|
|
optimization: {
|
|
minimizer: [
|
|
new TerserPlugin({
|
|
extractComments: false,
|
|
terserOptions: {
|
|
format: {
|
|
comments: /^!/ // Keep comments starting with !
|
|
}
|
|
}
|
|
})
|
|
]
|
|
},
|
|
output: {
|
|
libraryTarget: 'commonjs2'
|
|
},
|
|
stats: {
|
|
excludeModules: true
|
|
}
|
|
};
|