webpack.hot.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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: /\.(j|t)sx?$/,
  43. exclude: /node_modules/,
  44. use: [{
  45. loader: 'babel-loader',
  46. options: {
  47. cacheDirectory: true,
  48. babelrc: false,
  49. plugins: [
  50. ["@babel/plugin-proposal-class-properties", { loose: true }],
  51. 'angularjs-annotate',
  52. 'syntax-dynamic-import', // needed for `() => import()` in routes.ts
  53. 'react-hot-loader/babel'
  54. ],
  55. presets: [
  56. [
  57. '@babel/preset-env',
  58. {
  59. targets: { browsers: 'last 3 versions' },
  60. useBuiltIns: 'entry'
  61. }
  62. ],
  63. '@babel/preset-typescript',
  64. '@babel/preset-react'
  65. ],
  66. }
  67. }],
  68. },
  69. {
  70. test: /\.scss$/,
  71. use: [
  72. "style-loader", // creates style nodes from JS strings
  73. "css-loader", // translates CSS into CommonJS
  74. "sass-loader" // compiles Sass to CSS
  75. ]
  76. },
  77. {
  78. test: /\.(png|jpg|gif|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
  79. loader: 'file-loader'
  80. },
  81. ]
  82. },
  83. plugins: [
  84. new CleanWebpackPlugin('../public/build', { allowExternal: true }),
  85. new HtmlWebpackPlugin({
  86. filename: path.resolve(__dirname, '../../public/views/index.html'),
  87. template: path.resolve(__dirname, '../../public/views/index.template.html'),
  88. inject: 'body',
  89. alwaysWriteToDisk: true
  90. }),
  91. new HtmlWebpackHarddiskPlugin(),
  92. new webpack.NamedModulesPlugin(),
  93. new webpack.HotModuleReplacementPlugin(),
  94. new webpack.DefinePlugin({
  95. 'GRAFANA_THEME': JSON.stringify(process.env.GRAFANA_THEME || 'dark'),
  96. 'process.env': {
  97. 'NODE_ENV': JSON.stringify('development')
  98. }
  99. }),
  100. ]
  101. });