Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposed distPath configuration variable #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ npm install --save serverless-client-s3
],
"custom" : {
"client": {
"bucketName": "bucket.name.for.the.client"
"bucketName": "bucket.name.for.the.client",
"distPath": "client/dist" # default
}
}
```
Expand All @@ -32,7 +33,7 @@ npm install --save serverless-client-s3
* **Pro Tip:** To add staging and region functionality to your client, use Serverless Variables in the bucket name: `"bucket.name.for.the.client.${stage}.${region}"`


**Third**, Create a `client/dist` folder in the root directory of your Serverless project. This is where your distribution-ready website should live. It is recommended to have a `client/src` where you'll be developing your website, and a build script that outputs to `client/dist`. The plugin simply expects and uploads the entire `client/dist` folder to S3, configure the bucket to host the website, and make it publicly available.
**Third**, Create a folder in the root directory of your Serverless project to store your S3 Website resources (`client/dist` is the default location). This is where your distribution-ready website should live. It is recommended to have a `client/src` where you'll be developing your website, and a build script that outputs to `client/dist`. The plugin simply expects and uploads the entire `client/dist` folder to S3, configure the bucket to host the website, and make it publicly available.

Or just copy/run the following commands in the root directory of your Serverless project to get a quick sample website for deployment:

Expand Down
14 changes: 8 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ module.exports = function(S) {

let _this = this;

if (!S.utils.dirExistsSync(path.join(S.config.projectPath, 'client', 'dist'))) {
return BbPromise.reject(new SError('Could not find "client/dist" folder in your project root.'));
}

// validate stage: make sure stage exists
if (!S.getProject().validateStageExists(_this.evt.options.stage)) {
return BbPromise.reject(new SError('Stage ' + _this.evt.options.stage + ' does not exist in your project', SError.errorCodes.UNKNOWN));
Expand All @@ -112,8 +108,14 @@ module.exports = function(S) {
return BbPromise.reject(new SError('Please specify a bucket name for the client in s-project.json'));
}

_this.distPath = populatedProject.custom.client.distPath || "client/dist";

if (!S.utils.dirExistsSync(path.join(S.config.projectPath, _this.distPath))) {
return BbPromise.reject(new SError('Could not find "' + _this.distPath + '" folder in your project root.'));
}

_this.bucketName = populatedProject.custom.client.bucketName;
_this.clientPath = path.join(_this.project.getRootPath(), 'client', 'dist');
_this.clientPath = path.join(_this.project.getRootPath(), _this.distPath);

return BbPromise.resolve();
}
Expand Down Expand Up @@ -262,4 +264,4 @@ module.exports = function(S) {

}
return ClientDeploy;
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless-client-s3",
"version": "2.0.0",
"version": "2.0.1",
"engines": {
"node": ">=4.0"
},
Expand Down