webpack.hot.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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: 'awesome-typescript-loader',
  40. options: {
  41. useCache: true,
  42. useBabel: true,
  43. babelOptions: {
  44. babelrc: false,
  45. plugins: [
  46. 'syntax-dynamic-import',
  47. 'react-hot-loader/babel'
  48. ]
  49. }
  50. },
  51. }
  52. },
  53. {
  54. test: /\.scss$/,
  55. use: [
  56. "style-loader", // creates style nodes from JS strings
  57. "css-loader", // translates CSS into CommonJS
  58. "sass-loader" // compiles Sass to CSS
  59. ]
  60. },
  61. {
  62. test: /\.(png|jpg|gif|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
  63. loader: 'file-loader'
  64. },
  65. ]
  66. },
  67. plugins: [
  68. new CleanWebpackPlugin('../public/build', { allowExternal: true }),
  69. new HtmlWebpackPlugin({
  70. filename: path.resolve(__dirname, '../../public/views/index.html'),
  71. template: path.resolve(__dirname, '../../public/views/index.template.html'),
  72. inject: 'body',
  73. alwaysWriteToDisk: true
  74. }),
  75. new HtmlWebpackHarddiskPlugin(),
  76. new webpack.NamedModulesPlugin(),
  77. new webpack.HotModuleReplacementPlugin(),
  78. new webpack.DefinePlugin({
  79. 'GRAFANA_THEME': JSON.stringify(process.env.GRAFANA_THEME || 'dark'),
  80. 'process.env': {
  81. 'NODE_ENV': JSON.stringify('development')
  82. }
  83. }),
  84. ]
  85. });