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

configure sam build --watch support #39

Open
asankagit opened this issue Apr 4, 2020 · 5 comments
Open

configure sam build --watch support #39

asankagit opened this issue Apr 4, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@asankagit
Copy link

I use aws-sam-webpack-plugin with webpack to build the files.

webpack.config.js

const AwsSamPlugin = require("aws-sam-webpack-plugin");
const awsSamPlugin = new AwsSamPlugin();
const path = require('path');

module.exports = {
    //entry: './app.js',
    entry: () => awsSamPlugin.entry(),
    output: {
      path: path.resolve("."),
      filename: (chunkData) => awsSamPlugin.filename(chunkData),
      libraryTarget: 'commonjs'
    },
    target: 'node',
    mode: 'production',

      // Add the AWS SAM Webpack plugin
    plugins: [awsSamPlugin]

}

instead of using sam buld I use npm run build
in package.json

....
 "scripts": {
    "test": "mocha tests/unit/",
    "build": "webpack --watch "
  },
.....

although webpack rebuild the changes, it does not appear when sam local start-api
is running,
I am looking help for configure to appear changes

@asankagit asankagit changed the title configure sam build --wathc support configure sam build --watch support Apr 4, 2020
@buggy buggy added the question Further information is requested label Apr 7, 2020
@buggy
Copy link
Collaborator

buggy commented Apr 13, 2020

@asankagit Are you saying that changes to the functions aren't appearing or that changes to your SAM project aren't appearing?

@asankagit
Copy link
Author

yes I have configured my webpack.config.js and package.js as above

@a-mukubayashi
Copy link

@asankagit
Maybe you can achieve this by using two terminals.

## 1st terminal
npm run build
## 2nd terminal
sam local start-api

@ryansonshine
Copy link

@asankagit
One solution could be to use something like concurrently like I've used on my boilerplate

The reason for the initial npm run build is to ensure the container doesn't start up with old files or an empty directory.

@buggy buggy added enhancement New feature or request and removed question Further information is requested labels Apr 24, 2021
@MarsianMan
Copy link

Webpack watch does seem to work for me. The slowness makes it hard to tell if latest changes are completed or still a in progress. Sometimes I could see a build complete just as I get ready to run, but it was actually a previous build that had not finished but did not have latest changes.

I found it more efficient to manually run the build than keep wondering if I needed to wait longer for the "latest" change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants