webpack 安装与使用
安装 v5.x
sh
npm install webpack --save-dev
配置 webpack
webpack.config.js
javascript
const path = require("path");
module.exports = {
entry: "./src/index.js",
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist"),
},
};
webpack-dev-server
sh
npm install --save-dev webpack-dev-server
webpack.config.js
javascript
const path = require("path");
module.exports = {
entry: "./src/index.js",
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist"),
},
devServer: {
historyApiFallback: true,
},
};