项目打包
- yarn build或者npm build
需要上传的文件
1. .nuxt目录
2. package.json
3. nuxt.config.js
4. static
5. server目录 (不传会报错ERROR Renderer is loaded but not all resources are unavailable! Please check /www/wwwroot/sanwei/.nuxt/dist/server existence.)
项目打包后上传到OSS
1.需要创建一个deploy.js
- const OSS = require("ali-oss");
- const fs = require("fs");
- const path = require("path");
- const os = require("os");
- const PUBLIC_PATH = path.join(__dirname, "/");
- //需要替换成自己的
- const client = new OSS({
- region: 'oss的地理位置',
- accessKeyId: ' accessKeyId',
- accessKeySecret: ' accessKeySecret',
- bucket: 'bucket名字'
- })
- /**
- *获取文件目录并删除
- * @param {*} dir //文件目录
- */
- async function deleteDir(dir) {
- let result = await client.list({
- prefix: dir + "/",
- delimiter: "/"
- });
- if (result.objects) {
- let aa = [];
- result.objects.forEach(function (obj) {
- aa.push(obj.name);
- });
- try {
- await client.deleteMulti(aa, {
- quiet: true
- });
- consol