webpack.node.config.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. 'use strict';
  2. const path = require('path');
  3. const nodeExternals = require('webpack-node-externals');
  4. const webpack = require('webpack');
  5. const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
  6. const ForkTsCheckerNotifierWebpackPlugin = require('fork-ts-checker-notifier-webpack-plugin');
  7. const packageJson = require('pjson');
  8. const WebpackUtils = require('./utils/WebpackUtils').WebpackUtils;
  9. module.exports = {
  10. context: path.resolve(__dirname, '..'),
  11. devtool: 'source-map',
  12. entry: {
  13. 'index': './index.ts',
  14. 'index.cli': './index.cli.ts'
  15. },
  16. target: 'node',
  17. externals: [nodeExternals()],
  18. module: {
  19. exprContextCritical: false,
  20. rules: [
  21. {
  22. test: /\.ts$/,
  23. loader: 'ts-loader',
  24. options: {
  25. transpileOnly: true
  26. }
  27. }
  28. ]
  29. },
  30. resolve: {
  31. extensions: ['.ts']
  32. },
  33. plugins: [
  34. new webpack.BannerPlugin(
  35. {
  36. banner: WebpackUtils.getBannerText(
  37. WebpackUtils.getLicenseText(),
  38. WebpackUtils.getSourceMapSupportImport()
  39. ),
  40. raw: true,
  41. entryOnly: false
  42. }
  43. ),
  44. new webpack.EnvironmentPlugin({
  45. VERSION: packageJson.version,
  46. BUILD_TIMESTAMP: Date.now()
  47. }),
  48. new ForkTsCheckerWebpackPlugin({
  49. tsconfig: 'src/tsconfig.node.json',
  50. eslint: true
  51. }),
  52. new ForkTsCheckerNotifierWebpackPlugin({
  53. skipFirstNotification: true
  54. })
  55. ],
  56. output: {
  57. libraryTarget: 'commonjs2',
  58. library: 'JavaScriptObfuscator'
  59. },
  60. stats: {
  61. maxModules: 0
  62. }
  63. };