webpack.common.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. const path = require('path');
  2. module.exports = {
  3. target: 'web',
  4. entry: {
  5. app: './public/app/index.ts',
  6. },
  7. output: {
  8. path: path.resolve(__dirname, '../../public/build'),
  9. filename: '[name].[hash].js',
  10. // Keep publicPath relative for host.com/grafana/ deployments
  11. publicPath: 'public/build/',
  12. },
  13. resolve: {
  14. extensions: ['.ts', '.tsx', '.es6', '.js', '.json', '.svg'],
  15. alias: {
  16. },
  17. modules: [
  18. path.resolve('public'),
  19. path.resolve('node_modules')
  20. ],
  21. },
  22. stats: {
  23. children: false,
  24. warningsFilter: /export .* was not found in/
  25. },
  26. node: {
  27. fs: 'empty',
  28. },
  29. module: {
  30. rules: [
  31. {
  32. test: require.resolve('jquery'),
  33. use: [
  34. {
  35. loader: 'expose-loader',
  36. query: 'jQuery'
  37. },
  38. {
  39. loader: 'expose-loader',
  40. query: '$'
  41. }
  42. ]
  43. },
  44. {
  45. test: /\.html$/,
  46. exclude: /(index|error)\-template\.html/,
  47. use: [
  48. { loader: 'ngtemplate-loader?relativeTo=' + (path.resolve(__dirname, '../../public')) + '&prefix=public' },
  49. {
  50. loader: 'html-loader',
  51. options: {
  52. attrs: [],
  53. minimize: true,
  54. removeComments: false,
  55. collapseWhitespace: false
  56. }
  57. }
  58. ]
  59. }
  60. ]
  61. },
  62. // https://webpack.js.org/plugins/split-chunks-plugin/#split-chunks-example-3
  63. optimization: {
  64. splitChunks: {
  65. cacheGroups: {
  66. commons: {
  67. test: /[\\/]node_modules[\\/].*[jt]sx?$/,
  68. name: 'vendor',
  69. chunks: 'all'
  70. }
  71. }
  72. }
  73. }
  74. };