webpack.config.dev.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. entry: path.resolve(projectPath, 'src/index.js'),
  8. output: {
  9. path: path.resolve(__dirname, 'dist'),
  10. filename: 'bundle.js'
  11. },
  12. module: {
  13. rules: [
  14. {
  15. test: /\.js$/,
  16. loader: 'babel-loader',
  17. include: path.resolve(projectPath, 'src'),
  18. exclude: path.resolve(projectPath, "node_modules"),
  19. },
  20. {
  21. test: /\.css$/,
  22. use: [
  23. { loader: "style-loader" },
  24. {
  25. loader: "css-loader",
  26. options: {
  27. modules: true,
  28. camelCase: true,
  29. localIdentName: '[name]__[local]--[hash:base64:5]'
  30. }
  31. }
  32. ]
  33. },
  34. ]
  35. },
  36. plugins: [
  37. new webpack.HotModuleReplacementPlugin(),
  38. new HtmlWebpackPlugin({
  39. title: 'DatePicker',
  40. filename: 'index.html',
  41. template: path.resolve(projectPath, 'index.html'),
  42. inject: false
  43. })
  44. ],
  45. devServer: {
  46. port: 8080,
  47. contentBase: path.resolve(projectPath, 'build'),
  48. hot: true
  49. },
  50. }