您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》

cd webpack-test

cnpm init



cnpm install webpack --save-dev

dir

源文件目录 mkdir src 静态资源目录 mkdir dist


脚本目录 mkdir script 样式目录 mkdir style


cd dist mkdir js


cd ..
cd src
cd script
echo ... > main.js
main.js内容如下:
function helloWorld(){
}


echo ... > index.html 文件名:index.html 内容如下: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title></title> <link rel="stylesheet" href=""> </head> <body> <script src="bundle.js"></script> </body> </html>

echo ... > webpack.config.js
webpack.config.js内容如下:
module.exports={
entry:'./src/script/main.js',
output:{
path:'./dist/js',
filename:'bundle.js'
}
}

cd dist/js dir

ren webpack.config.js webpack.dev.config.js dir

webpack

webpack --config webpack.dev.config.js

{
"name": "webpack-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"webpack":"webpack --config webpack.config.js --progress --display-modules --colors --display-reason"
},
"author": "",
"license": "ISC",
"devDependencies": {
"webpack": "^2.2.1"
}
}cnpm run webpack

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。