webpack.hot.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. },
  21. resolve: {
  22. extensions: ['.scss', '.ts', '.tsx', '.es6', '.js', '.json', '.svg', '.woff2', '.png', '.html'],
  23. },
  24. devtool: 'eval-source-map',
  25. devServer: {
  26. publicPath: '/public/build/',
  27. hot: true,
  28. port: 3333,
  29. proxy: {
  30. '!/public/build': 'http://localhost:3000'
  31. }
  32. },
  33. module: {
  34. rules: [
  35. {
  36. test: /\.tsx?$/,
  37. exclude: /node_modules/,
  38. use: [{
  39. loader: 'babel-loader',
  40. options: {
  41. cacheDirectory: true,
  42. babelrc: false,
  43. plugins: [
  44. 'syntax-dynamic-import',
  45. 'react-hot-loader/babel'
  46. ]
  47. }
  48. },
  49. {
  50. loader: 'ts-loader',
  51. options: {
  52. transpileOnly: true
  53. },
  54. }],
  55. },
  56. {
  57. test: /\.scss$/,
  58. use: [
  59. "style-loader", // creates style nodes from JS strings
  60. "css-loader", // translates CSS into CommonJS
  61. "sass-loader" // compiles Sass to CSS
  62. ]
  63. },
  64. {
  65. test: /\.(png|jpg|gif|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
  66. loader: 'file-loader'
  67. },
  68. ]
  69. },
  70. plugins: [
  71. new CleanWebpackPlugin('../public/build', { allowExternal: true }),
  72. new HtmlWebpackPlugin({
  73. filename: path.resolve(__dirname, '../../public/views/index.html'),
  74. template: path.resolve(__dirname, '../../public/views/index.template.html'),
  75. inject: 'body',
  76. alwaysWriteToDisk: true
  77. }),
  78. new HtmlWebpackHarddiskPlugin(),
  79. new webpack.NamedModulesPlugin(),
  80. new webpack.HotModuleReplacementPlugin(),
  81. new webpack.DefinePlugin({
  82. 'GRAFANA_THEME': JSON.stringify(process.env.GRAFANA_THEME || 'dark'),
  83. 'process.env': {
  84. 'NODE_ENV': JSON.stringify('development')
  85. }
  86. }),
  87. ]
  88. });