webpack.node.config.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. cache: {
  34. type: 'filesystem',
  35. buildDependencies: {
  36. config: [
  37. __filename
  38. ]
  39. }
  40. },
  41. plugins: [
  42. new webpack.BannerPlugin(
  43. {
  44. banner: WebpackUtils.getBannerText(
  45. WebpackUtils.getLicenseText(),
  46. WebpackUtils.getSourceMapSupportImport()
  47. ),
  48. raw: true,
  49. entryOnly: false
  50. }
  51. ),
  52. new webpack.EnvironmentPlugin({
  53. VERSION: packageJson.version,
  54. BUILD_TIMESTAMP: Date.now()
  55. }),
  56. new ForkTsCheckerWebpackPlugin({
  57. eslint: {
  58. files: 'src/**/*.ts'
  59. },
  60. typescript: {
  61. configFile: 'src/tsconfig.node.json'
  62. }
  63. }),
  64. new ForkTsCheckerNotifierWebpackPlugin({
  65. skipFirstNotification: true
  66. })
  67. ],
  68. output: {
  69. libraryTarget: 'commonjs2'
  70. },
  71. stats: {
  72. excludeModules: true
  73. }
  74. };