1、配置config目录下的index.js

注意 assetsSubDirectory 不要和原来的冲突

build: {
    .....
    assetsSubDirectory: 'test-static',
    oss_publicPath: 'your publicPath',
    oss_accessKeyId: 'your key',
    oss_accessKeySecret: 'your secret',
    oss_region: 'your region',
    oss_bucket: 'your bucket'
    .....
  }
2、配置build目录下的webpack.prod.conf.js
const AliyunOSSPlugin = require("aliyun-oss-webpack-plugin")
....
	// 配置 output 的 publicPath
	output: {
	    publicPath: config.build.oss_publicPath,
	    ...
	  },
	// 配置 plugins
  plugins: [
    new AliyunOSSPlugin({
      accessKeyId: config.build.oss_accessKeyId,
      accessKeySecret: config.build.oss_accessKeySecret,
      region: config.build.oss_region,
      bucket: config.build.oss_bucket
    }),
    ....
    ]
....

运行 npm run build 进行测试
正常不报错 表示成功

Logo

前往低代码交流专区

更多推荐