webpack.hot.js 2.3 KB

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