AWS S3

要繼續部署到 S3,我們將安裝這些外掛:

由於它們是 Ember 外掛,你可以通過執行以下命令輕鬆安裝

ember install ember-cli-deploy-s3-index
ember install ember-cli-deploy-s3

之後你需要的是配置 deploy.js 檔案,該檔案應位於/ config 資料夾下:

// config/deploy.js

module.exports = function(deployTarget) {

  var ENV = {
    build: {
      environment: deployTarget
    },
    'revision-data': {
      type: 'git-commit'
    },
    's3-index': {
      accessKeyId: process.env['S3_ACCESS_KEY'],
      secretAccessKey: process.env['S3_SECRET_ACCESS_KEY'],
      bucket: "your-app-deployment-bucket",
      region: "YOUR REGISION",
      allowOverwrite: true // if you want to overwrite index file if not change it to false
    },
    's3': {
      accessKeyId: process.env['S3_ACCESS_KEY'],
      secretAccessKey: process.env['S3_SECRET_ACCESS_KEY'],
      bucket: "your-app-deployment-bucket",
      region: "YOUR REGISION",
    }
  };

  return ENV;

};

請注意,我們在 config 中使用了環境變數。如果需要從檔案中讀取配置,也可以返回使用 ENV 物件解析的 promise。以下是在 deploy.js 檔案中定義不同環境的示例:

if (deployTarget === 'development') {
    ENV.build.environment = 'development';
    // configure other plugins for development deploy target here
  }

  if (deployTarget === 'staging') {
    ENV.build.environment = 'production';
    // configure other plugins for staging deploy target here
  }

  if (deployTarget === 'production') {
    ENV.build.environment = 'production';
    // configure other plugins for production deploy target here
  }

最後,你可以輕鬆執行以下命令進行部署

ember deploy [YOUR APP ENVIRONMENT] //e.g-> ember deploy production or ember deploy staging

如果你想檢視可以執行的詳細資訊:

ember deploy production --verbose --activate=true