webpack.node.config.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 packageJson = require('pjson');
  7. const WebpackUtils = require('./utils/WebpackUtils').WebpackUtils;
  8. module.exports = {
  9. context: path.resolve(__dirname, '..'),
  10. devtool: 'source-map',
  11. entry: {
  12. 'index': './index.ts',
  13. 'index.cli': './index.cli.ts'
  14. },
  15. target: 'node',
  16. externals: [nodeExternals()],
  17. module: {
  18. exprContextCritical: false,
  19. rules: [
  20. {
  21. test: /\.ts$/,
  22. loader: 'ts-loader',
  23. options: {
  24. transpileOnly: true
  25. }
  26. }
  27. ]
  28. },
  29. resolve: {
  30. extensions: ['.ts']
  31. },
  32. plugins: [
  33. new webpack.BannerPlugin(
  34. {
  35. banner: WebpackUtils.getBannerText(
  36. WebpackUtils.getLicenseText(),
  37. WebpackUtils.getSourceMapSupportImport()
  38. ),
  39. raw: true,
  40. entryOnly: false
  41. }
  42. ),
  43. new webpack.EnvironmentPlugin({
  44. VERSION: packageJson.version
  45. }),
  46. new ForkTsCheckerWebpackPlugin({
  47. tsconfig: 'src/tsconfig.node.json',
  48. tslint: './tslint.json'
  49. })
  50. ],
  51. output: {
  52. libraryTarget: 'commonjs2',
  53. library: 'JavaScriptObfuscator'
  54. },
  55. stats: {
  56. maxModules: 0
  57. }
  58. };