webpack.02-How to pack

Posted May 27, 20201 min read

Initialize in empty folder:CMD

npm init -y

\ -y means all yes

cnpm install -D webpack webpack-cli

File structure

src(folder) ---> index.js

console.log('hello webpack')

test(folder) ---> main.js

console.log('hello webpack2')


add build:webpack inside scripts
webpack defaults to packing index.js under src which can be customized, such as:build:webpack server/index.js

    "build2":"webpack test/main.js"
    "webpack":"^ 4.43.0",
    "webpack-cli":"^ 3.3.11"


npm run build
npm run build2