webpack.config.dev.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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[x]?$/,
  16. enforce: 'pre',
  17. use: [{
  18. loader: 'eslint-loader',
  19. options: { fix: true },
  20. }],
  21. include: path.resolve(projectPath, './src/**/*.js'),
  22. exclude: [
  23. /node_modules/,
  24. path.resolve(projectPath, './webpack/**/*.js'),
  25. ],
  26. },
  27. {
  28. test: /\.js$/,
  29. loader: 'babel-loader',
  30. // include: path.resolve(projectPath, './src/**/*.js'),
  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. },
  49. plugins: [
  50. new webpack.HotModuleReplacementPlugin(),
  51. new HtmlWebpackPlugin({
  52. title: 'DatePicker',
  53. filename: 'index.html',
  54. template: path.resolve(projectPath, 'index.html'),
  55. inject: false,
  56. }),
  57. ],
  58. devServer: {
  59. port: 8080,
  60. contentBase: path.resolve(projectPath, 'dist'),
  61. hot: true,
  62. },
  63. }