webpack.dev.js 902 B

123456789101112131415161718192021222324252627
  1. var path = require('path')
  2. var webpack = require('webpack')
  3. const WebpackMerge = require('webpack-merge')
  4. const baseConfig = require('./webpack.base.js')
  5. let HtmlWebpackPlugin = require('html-webpack-plugin');
  6. module.exports = WebpackMerge.merge(baseConfig, {
  7. mode: 'development',
  8. entry: path.join(__dirname, 'examples/main.js'), // 入口文件
  9. output: {
  10. path: path.join(__dirname, 'dist'), // 打包后文件存放的地方
  11. filename: 'dist/build.js' // 打包后输出的文件名
  12. },
  13. devServer: {
  14. port: 8086,
  15. historyApiFallback: true,
  16. },
  17. devtool: 'source-map',
  18. plugins: (module.exports.plugins || []).concat([
  19. new HtmlWebpackPlugin({ // html-webpack-plugin 插件对象
  20. template: path.join(__dirname, './index.html'), // 指定模板文件
  21. filename: 'index.html' // 设置内存中的文件名
  22. })
  23. ])
  24. })