webpack.config.dev.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. const path = require('path')
  2. const webpack = require('webpack')
  3. const HtmlWebpackPlugin = require('html-webpack-plugin')
  4. const projectPath = path.resolve(__dirname, '../')
  5. module.exports = {
  6. mode: 'development',
  7. devtool: 'eval-source-map',
  8. entry: path.resolve(projectPath, 'src/app.js'),
  9. output: {
  10. path: path.resolve(__dirname, 'dist'),
  11. filename: 'bundle.js',
  12. },
  13. module: {
  14. rules: [
  15. {
  16. test: /\.js[x]?$/,
  17. enforce: 'pre',
  18. use: [{
  19. loader: 'eslint-loader',
  20. options: { fix: true },
  21. }],
  22. include: path.resolve(projectPath, './src/**/*.js'),
  23. exclude: [
  24. /node_modules/,
  25. path.resolve(projectPath, './webpack/**/*.js'),
  26. ],
  27. },
  28. {
  29. test: /\.js$/,
  30. loader: 'babel-loader',
  31. exclude: /node_modules/,
  32. },
  33. {
  34. test: /\.css$/,
  35. use: [
  36. { loader: 'style-loader' },
  37. {
  38. loader: 'css-loader',
  39. options: {
  40. modules: true,
  41. camelCase: true,
  42. localIdentName: '[name]__[local]--[hash:base64:5]',
  43. },
  44. },
  45. ],
  46. },
  47. {
  48. test: /\.(jpe?g|png|svg|bmp)$/,
  49. loader: 'file-loader',
  50. options: {
  51. name: '[name].[ext]',
  52. },
  53. },
  54. ],
  55. },
  56. plugins: [
  57. new webpack.HotModuleReplacementPlugin(),
  58. new HtmlWebpackPlugin({
  59. title: 'DatePicker',
  60. filename: 'index.html',
  61. template: path.resolve(projectPath, 'index.html'),
  62. inject: false,
  63. }),
  64. ],
  65. devServer: {
  66. port: 8080,
  67. contentBase: path.resolve(projectPath, 'dist'),
  68. hot: true,
  69. },
  70. }