webpack.config.js配置(development&production)

本文详细介绍了如何根据不同模式配置webpack.config.js,包括development.config.js和production.config.js,以及核心的webpack.config.js文件的设置,确保项目在开发和生产环境下的优化构建。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

development.config.js

//引入html-webpack-plugin模块,目的是生成index.html模板
const HtmlWebpackPlugin=require('html-webpack-plugin');
//引入vue-loader中的plugin,才能成功编译.vue文件
const VueLoaderPlugin=require('vue-loader/lib/plugin');

module.exports={
 //模式为开发模式
  mode: 'development',
  //出口
  output: {
 	/*
	不需要输出,因为开发模式,编译的bundle.js文件输出内存里
	output: path.resolve(__dirname,'dest');
	*/
    filename: 'bundle.js'
  },
  //开启调试定位,若文件编译发生错误,定位到具体哪个文件
  devtool: 'source-map',
  
  plugins: [
  //以index.html为模板编译Html,避免每次都在index.html源文件中引入bundle.js文件
    new HtmlWebpackPlugin({
      template: 'index.html'
    }),
    //调用Vue中的plugin,以便成功编译 .vue文件
    new VueLoaderPlugin()
  ]
};

production.config.js

const path=require('path');

const HtmlWebpackPlugin=require(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值