webpack.node.config.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 ESLintPlugin = require('eslint-webpack-plugin');
  8. const packageJson = require('pjson');
  9. const WebpackUtils = require('./utils/WebpackUtils').WebpackUtils;
  10. module.exports = {
  11. context: path.resolve(__dirname, '..'),
  12. devtool: 'source-map',
  13. entry: {
  14. 'index': './index.ts',
  15. 'index.cli': './index.cli.ts'
  16. },
  17. target: 'node',
  18. externals: [nodeExternals()],
  19. module: {
  20. exprContextCritical: false,
  21. rules: [
  22. {
  23. test: /\.ts$/,
  24. loader: 'ts-loader',
  25. options: {
  26. transpileOnly: true
  27. }
  28. }
  29. ]
  30. },
  31. resolve: {
  32. extensions: ['.ts']
  33. },
  34. cache: {
  35. type: 'filesystem',
  36. buildDependencies: {
  37. config: [
  38. __filename
  39. ]
  40. }
  41. },
  42. plugins: [
  43. new webpack.BannerPlugin(
  44. {
  45. banner: WebpackUtils.getBannerText(
  46. WebpackUtils.getLicenseText(),
  47. WebpackUtils.getSourceMapSupportImport()
  48. ),
  49. raw: true,
  50. entryOnly: false
  51. }
  52. ),
  53. new webpack.EnvironmentPlugin({
  54. VERSION: packageJson.version,
  55. BUILD_TIMESTAMP: Date.now()
  56. }),
  57. new ForkTsCheckerWebpackPlugin({
  58. typescript: {
  59. configFile: 'src/tsconfig.node.json'
  60. }
  61. }),
  62. new ESLintPlugin({
  63. files: 'src/**/*.ts'
  64. }),
  65. new ForkTsCheckerNotifierWebpackPlugin({
  66. skipFirstNotification: true
  67. })
  68. ],
  69. output: {
  70. libraryTarget: 'commonjs2'
  71. },
  72. stats: {
  73. excludeModules: true
  74. }
  75. };