webpack.dev.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* eslint-disable */
  2. /**
  3. * @author: Yuki Takei <yuki@weseek.co.jp>
  4. */
  5. const path = require('path');
  6. /*
  7. * Webpack Plugins
  8. */
  9. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  10. const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
  11. const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
  12. /**
  13. * Webpack Constants
  14. */
  15. const { ANALYZE } = process.env;
  16. module.exports = require('./webpack.common')({
  17. mode: 'development',
  18. devtool: 'cheap-module-eval-source-map',
  19. entry: {
  20. 'js/dev': './src/client/dev',
  21. },
  22. resolve: {
  23. modules: ['../node_modules'],
  24. },
  25. module: {
  26. rules: [
  27. {
  28. test: /\.(css|scss)$/,
  29. use: [
  30. 'style-loader',
  31. { loader: 'css-loader', options: { sourceMap: true } },
  32. { loader: 'sass-loader', options: { sourceMap: true } },
  33. ],
  34. exclude: [
  35. path.resolve(__dirname, '../src/styles-hackmd'),
  36. path.resolve(__dirname, '../src/styles/style-presentation.scss'),
  37. ],
  38. },
  39. { // Dump CSS for HackMD
  40. test: /\.(css|scss)$/,
  41. use: [
  42. MiniCssExtractPlugin.loader,
  43. 'css-loader',
  44. 'sass-loader',
  45. ],
  46. include: [
  47. path.resolve(__dirname, '../src/styles-hackmd'),
  48. path.resolve(__dirname, '../src/styles/style-presentation.scss'),
  49. ],
  50. },
  51. ],
  52. },
  53. plugins: [
  54. new MiniCssExtractPlugin({
  55. filename: '[name].bundle.css',
  56. }),
  57. new BundleAnalyzerPlugin({
  58. analyzerMode: ANALYZE ? 'server' : 'disabled',
  59. }),
  60. new HardSourceWebpackPlugin(),
  61. new HardSourceWebpackPlugin.ExcludeModulePlugin([
  62. {
  63. // see https://github.com/mzgoddard/hard-source-webpack-plugin/blob/master/README.md#excludemoduleplugin
  64. test: /mini-css-extract-plugin[\\/]dist[\\/]loader/,
  65. },
  66. ]),
  67. ],
  68. optimization: {},
  69. performance: {
  70. hints: false,
  71. },
  72. });