webpack.dev.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * @author: Yuki Takei <yuki@weseek.co.jp>
  3. */
  4. const webpack = require('webpack');
  5. const helpers = require('../src/lib/util/helpers');
  6. /*
  7. * Webpack Plugins
  8. */
  9. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  10. const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
  11. /**
  12. * Webpack Constants
  13. */
  14. const ANALYZE = process.env.ANALYZE;
  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 webpack.DllReferencePlugin({
  57. context: helpers.root(),
  58. manifest: require(helpers.root('public/dll', 'manifest.json')),
  59. }),
  60. new BundleAnalyzerPlugin({
  61. analyzerMode: ANALYZE ? 'server' : 'disabled',
  62. }),
  63. ],
  64. optimization: {},
  65. performance: {
  66. hints: false
  67. }
  68. });