webpack.config.js 704 B

123456789101112131415161718192021222324252627282930
  1. const path = require('path')
  2. const HtmlWebpackPlugin = require('html-webpack-plugin')
  3. module.exports = {
  4. mode: 'development', // ['development', 'production']
  5. entry: path.join(__dirname, 'src', 'index.js'),
  6. output: {
  7. filename: 'bundle.js',
  8. path: path.join(__dirname, 'dist')
  9. },
  10. module: {
  11. rules: [
  12. {
  13. test: /\.js$/,
  14. loader: ['babel-loader'],
  15. include: path.join(__dirname, 'src'),
  16. exclude: /node_modules/
  17. }
  18. ]
  19. },
  20. plugins: [
  21. new HtmlWebpackPlugin({
  22. template: path.join(__dirname, 'src', 'index.html'),
  23. filename: 'index.html'
  24. })
  25. ],
  26. devServer: {
  27. port: 3001,
  28. contentBase: path.join(__dirname, 'dist')
  29. }
  30. }