webpack.config.js 1.2 KB

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