Added script to assets/scripts and to manifest.json main.js files, but it's not being included

I’ve added a new script to /assets/scripts and included the file in the manifest like:

"main.js": {
    "files": [
        "scripts/main.js",
        "scripts/my-custom-script.js"
    ],
    "main": true
}

No matter what order I place it in, my script is not being added to the compiled result.

gulp watch keeps saying: 3 files changed (modernizr-45f0e1f4.js, jquery-cb5eadd1.js, main-c1dcc4cd.js)

But it never reflects any changes in those files. When there are changes the hash is suppose to change as well.

Thanks.

Yep, I’m experiencing the same thing.

I’ve added myjs.js to assests/scripts. Then, I referenced it in manifest.json as seen below. But, it’s not being compiled to main.js file. I know main.js is being watched because if I write to it, the update takes effect via Browsersync.

…
    "main.js": {
      "files": [
        "scripts/myjs.js", 
        "scripts/main.js"
      ],
      "main": true
    },
…

Sometimes you just need to stop gulp watch, and run gulp && gulp watch again

@kalenjohnson Not watching, but just running gulp produces an error, so that doesn’t seem to be the case.

I’ve read in an older discussion to set it up like it’s written below, but wasn’t sure if this was outdated procedure.

Also, while the following works, there’s no way to have assets/scripts/vendor/slider.js file to run before assets/scripts/main.js when dist/main.js is compiled:

"dependencies": {
  "main.js": {
    "vendor": [
     "assets/scripts/vendor/slider.js"
    ],
    "files": [
      "scripts/main.js"
    ],
  "main": true
},

I think you are running into this bug: Ordering stylesheets before gulp-concat

Needs to get patched. @joemaller let’s kill this.

Was this issue ever solved? I’m having the same issue with any .js files I add to the /assets/scripts folder.

I have a related question. Here’s my process for building style.css:

  1. Create new assets/styles/_partial.scss
  2. @import in assets/styles/main.scss
  3. Gulp build into dist/styles/main.css

Should scripts be built the same way?

  1. Create new assets/scripts/function.js
  2. Add new file to dependences > main.js > files in assets/manifest.json
  3. Gulp build into dist/scripts/main.js

I’m trying to prevent main.js from becoming spaghetti code more so than it already is!

1 Like

Yes, if you are adding your own script, you do need to add it to manifest.json

Yes, if you are adding your own script, you do need to add it to manifest.json

Sweet, so then I can confirm that this problem still exists. When I do similar to OP, I do not see the code from my-custom-script.js in the build version of main.js.

Is there any progress to fix this issue? Or maybe there’s an alternative that I don’t know about?

Hey, no news here ? I’m facing the same issue with JS dependencies.

Was getting the same thing, except I was only adding a js file, no styles. I checked the asset-builder globs and my added script was different than the others, because it was missing the assets folder prefixed to the path. It makes sense because in the screencast and on the asset-builder docs it’s going two directories up instead of three to get to plugins. So, concluding the “problem” here is that the “vendor” type starts in the theme folder not the assets folder - for some reason :slight_smile: while “files” starts in the assets folder. Hope I have this right… seems to check out as I’ve just tried it.

1 Like

I can confirm this, had to append assets/when using the vendor-type in manifest.json.

2 Likes

Yes, thank you.
That was not that obvious…

1 Like