webpack.dev.js 1.9 KB

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