源码 链接:https://pan.baidu.com/s/1BruNhJhP_Zbw9BPahSXqRw 密码:8mjs
webpack.config.js
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './main.js',
output: {
filename: 'build.js',
path: path.resolve(__dirname, 'dist')
},
plugins: [
//打包html
new HtmlWebpackPlugin({
title: 'Output Management',
template: './source.html'
}),
],
//引第三方插件
externals: {
jquery: 'jQuery',
react: 'React',
reactDom: 'ReactDOM'
},
//调试工具
devtool: 'inline-source-map',
module: {
rules: [{
//兼容jsx语法
test: /\.js?$/,
use: {
loader: 'babel-loader',