webpack.dev.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 CleanWebpackPlugin = require('clean-webpack-plugin');
  8. const MiniCssExtractPlugin = require("mini-css-extract-plugin");
  9. // const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
  10. module.exports = merge(common, {
  11. devtool: "cheap-module-source-map",
  12. mode: 'development',
  13. entry: {
  14. app: './public/app/index.ts',
  15. dark: './public/sass/grafana.dark.scss',
  16. light: './public/sass/grafana.light.scss',
  17. },
  18. // If we enabled watch option via CLI
  19. watchOptions: {
  20. ignored: /node_modules/
  21. },
  22. module: {
  23. rules: [
  24. {
  25. test: /\.tsx?$/,
  26. enforce: 'pre',
  27. exclude: /node_modules/,
  28. use: {
  29. loader: 'tslint-loader',
  30. options: {
  31. emitErrors: true,
  32. typeCheck: false,
  33. }
  34. }
  35. },
  36. {
  37. test: /\.tsx?$/,
  38. exclude: /node_modules/,
  39. use: {
  40. loader: 'ts-loader',
  41. options: {
  42. transpileOnly: true
  43. },
  44. },
  45. },
  46. require('./sass.rule.js')({ sourceMap: false, preserveUrl: false }),
  47. {
  48. test: /\.(png|jpg|gif|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
  49. loader: 'file-loader'
  50. },
  51. ]
  52. },
  53. plugins: [
  54. new CleanWebpackPlugin(),
  55. new MiniCssExtractPlugin({
  56. filename: "grafana.[name].[hash].css"
  57. }),
  58. new HtmlWebpackPlugin({
  59. filename: path.resolve(__dirname, '../../public/views/error.html'),
  60. template: path.resolve(__dirname, '../../public/views/error-template.html'),
  61. inject: false,
  62. }),
  63. new HtmlWebpackPlugin({
  64. filename: path.resolve(__dirname, '../../public/views/index.html'),
  65. template: path.resolve(__dirname, '../../public/views/index-template.html'),
  66. inject: 'body',
  67. chunks: ['manifest', 'vendor', 'app'],
  68. }),
  69. new webpack.NamedModulesPlugin(),
  70. new webpack.HotModuleReplacementPlugin(),
  71. new webpack.DefinePlugin({
  72. 'process.env': {
  73. 'NODE_ENV': JSON.stringify('development')
  74. }
  75. }),
  76. // new BundleAnalyzerPlugin({
  77. // analyzerPort: 8889
  78. // })
  79. ]
  80. });