在空文件夾初始化:CMDhtml
npm init -ywebpack
-y意思是所有yescnpm install -D webpack webpack-cliweb
文件結構npm
src(文件夾)--->index.js
console.log('hello webpack')
test(文件夾)--->main.js
console.log('hello webpack2')
package.jsonjson
scripts裏面加上build:webpack
webpack默認是打包src下面的index.js 能夠自定義,如:build:webpack server/index.js
{ "name": "02", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "build": "webpack", "build2": "webpack test/main.js" }, "keywords": [], "author": "", "license": "ISC", "devDependencies": { "webpack": "^4.43.0", "webpack-cli": "^3.3.11" } }
打包:CMDsegmentfault
npm run build
npm run build2