webpack.hot.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. 'use strict';
  2. const merge = require('webpack-merge');
  3. const common = require('./webpack.common.js');
  4. const path = require('path');
  5. const webpack = require('webpack');
  6. const HtmlWebpackPlugin = require("html-webpack-plugin");
  7. const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');
  8. const CleanWebpackPlugin = require('clean-webpack-plugin');
  9. module.exports = merge(common, {
  10. entry: {
  11. app: [
  12. 'webpack-dev-server/client?http://localhost:3333',
  13. './public/app/dev.ts',
  14. ],
  15. },
  16. output: {
  17. path: path.resolve(__dirname, '../../public/build'),
  18. filename: '[name].[hash].js',
  19. publicPath: "/public/build/",
  20. pathinfo: false,
  21. },
  22. resolve: {
  23. extensions: ['.scss', '.ts', '.tsx', '.es6', '.js', '.json', '.svg', '.woff2', '.png', '.html'],
  24. },
  25. devtool: 'eval-source-map',
  26. devServer: {
  27. publicPath: '/public/build/',
  28. hot: true,
  29. port: 3333,
  30. proxy: {
  31. '!/public/build': 'http://localhost:3000'
  32. }
  33. },
  34. optimization: {
  35. removeAvailableModules: false,
  36. removeEmptyChunks: false,
  37. splitChunks: false,
  38. },
  39. module: {
  40. rules: [
  41. {
  42. test: /\.tsx?$/,
  43. exclude: /node_modules/,
  44. use: [{
  45. loader: 'babel-loader',
  46. options: {
  47. cacheDirectory: true,
  48. babelrc: false,
  49. plugins: [
  50. 'syntax-dynamic-import',
  51. 'react-hot-loader/babel'
  52. ]
  53. }
  54. },
  55. {
  56. loader: 'ts-loader',
  57. options: {
  58. transpileOnly: true,
  59. experimentalWatchApi: true
  60. },
  61. }],
  62. },
  63. {
  64. test: /\.scss$/,
  65. use: [
  66. "style-loader", // creates style nodes from JS strings
  67. "css-loader", // translates CSS into CommonJS
  68. "sass-loader" // compiles Sass to CSS
  69. ]
  70. },
  71. {
  72. test: /\.(png|jpg|gif|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
  73. loader: 'file-loader'
  74. },
  75. ]
  76. },
  77. plugins: [
  78. new CleanWebpackPlugin('../public/build', { allowExternal: true }),
  79. new HtmlWebpackPlugin({
  80. filename: path.resolve(__dirname, '../../public/views/index.html'),
  81. template: path.resolve(__dirname, '../../public/views/index-template.html'),
  82. inject: 'body',
  83. alwaysWriteToDisk: true
  84. }),
  85. new HtmlWebpackHarddiskPlugin(),
  86. new webpack.NamedModulesPlugin(),
  87. new webpack.HotModuleReplacementPlugin(),
  88. new webpack.DefinePlugin({
  89. 'GRAFANA_THEME': JSON.stringify(process.env.GRAFANA_THEME || 'dark'),
  90. 'process.env': {
  91. 'NODE_ENV': JSON.stringify('development')
  92. }
  93. }),
  94. ]
  95. });