1.安装 webpack-dev-server
2.配置package.json "dev":"webpack-dev-server --config webpack.config.js"
3.配置编译目标,在webpack.config.js中补充target:'web'
4.根据不同的环境判断(开发环境/正式环境) 安装cross-env
5.在package.json中,利用corss-env判断环境.
"build": "cross-env NODE_ENV=production webpack --config webpack.config.js",
"dev": "cross-env NODE_ENV=development webpack-dev-server --config webpack.config.js"
6.在webpack.config.js写判断逻辑
7.js需要加载到一个html里面运行,利用html-webpack-plugin 安装它