配置webpack 的打包发布
在 package.json 文件的 scripts 节点下,新增build命令如下:
"scripts": {
"dev": "webpack serve",
"build": "webpack --mode production"//项目发布时,运行build命令
}
--model
是一个参数项,用来指定webpack的运行模式。production代表生产环境,会对打包生成的文件进行压缩和性能优化。
注意:通过 --model 指定的参数项,会覆盖 webpack.config.js 中的 model 选项。
将打包好的js放入到js文件夹下
在webpack.config.js配置文件的output 节点中,进行如下配置
把图片放入images下
同样是在webpack.config.js中配置
clean-webpack-plugin的使用
注意: 这里面导入构造函数的时候会有一个解构赋值的语法,将右侧对象中的某个属性解构出来
vue 项目的打包发布
npm run build
module.exports = {
publicPath : process.env.NODE_ENV === 'production' ? './' : '/'
}
nginx 的安装见另一片文章
https://editor.youkuaiyun.com/md/?articleId=120774204
把打包好的文件放入到服务器的nginx安装目录下 这里是/usr/local/nginx
启动nginx
cd到nginx的sbin目录
cd /usr/local/nginx/sbin
进入nginx目录中
cd /usr/local/nginx/sbin
1、查看 nginx版本号
./nginx -v
2、启动 nginx
./nginx
3、停止nginx
./nginx -s stop
./nginx -s quit
4、重新加载 nginx
./nginx -s reload
5、查看nginx进程
ps -ef | grep nginx
访问即可