webpack.config.js 1.3 KB

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