webpack.config.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. 'use strict';
  2. const fs = require("fs");
  3. const nodeExternals = require('webpack-node-externals');
  4. const webpack = require('webpack');
  5. const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;
  6. function getLicenseText () {
  7. return "/*\nCopyright (C) 2017 Timofey Kachalov <[email protected]>\n\n" +
  8. fs.readFileSync('./LICENSE.BSD', 'utf8') + "\n*/";
  9. }
  10. module.exports = {
  11. entry: {
  12. 'index': './index.ts'
  13. },
  14. devtool: 'source-map',
  15. target: 'node',
  16. externals: [nodeExternals()],
  17. module: {
  18. rules: [
  19. {
  20. enforce: 'pre',
  21. test: /\.ts$/,
  22. loader: 'tslint-loader',
  23. exclude: /(node_modules)/,
  24. },
  25. {
  26. test: /\.ts(x?)$/,
  27. loader: 'awesome-typescript-loader',
  28. query: {
  29. useBabel: true,
  30. useCache: true
  31. }
  32. }
  33. ]
  34. },
  35. resolve: {
  36. extensions: ['.ts']
  37. },
  38. plugins: [
  39. new webpack.BannerPlugin(
  40. {
  41. banner: getLicenseText() + '\n\nrequire("source-map-support").install();\n',
  42. raw: true,
  43. entryOnly: false
  44. }
  45. ),
  46. new CheckerPlugin()
  47. ],
  48. output: {
  49. path: './dist',
  50. filename: '[name].js',
  51. libraryTarget: "commonjs2",
  52. library: "JavaScriptObfuscator"
  53. },
  54. stats: {
  55. maxModules: 0
  56. }
  57. };