Menu icon Foundation
Adding JS files to src/assets/js

I'm using Yeti Launch and a "Zurb Template" (i.e., handlebars, etc). I'd like to add additional .js files to the /src/assets/js/ directory, but when I do, they are not being copied into the corresponding dist folder. I'm not sure what I'm doing wrong. Can anyone point me in the right direction?

Thanks,

Ben

yeti launchjs

I'm using Yeti Launch and a "Zurb Template" (i.e., handlebars, etc). I'd like to add additional .js files to the /src/assets/js/ directory, but when I do, they are not being copied into the corresponding dist folder. I'm not sure what I'm doing wrong. Can anyone point me in the right direction?

Thanks,

Ben

craig bane over 3 years ago

I've been using bower to install the js library for example velocity then editing the gulpfile and just including the path.

Not sure if this is the right thing to do however I do know its working for me

Ben Delaney over 3 years ago

Thanks Craig,

I tried including the file in the gulpfile.js and had no luck. I put it in the javascript array...

var PATHS = {
    javascript: [
        'src/assets/js/myfile.js'
    ]
}

Is this how you're doing it?

Rafi Benkual over 3 years ago

You add the path to the Gulfile under JavaScript

javascript: [
    'bower_components/jquery/dist/jquery.js',
    'bower_components/what-input/what-input.js',
    'bower_components/owlcarousel/owl-carousel/owl.carousel.js',

There is a built in gulp task to copy into the dist folder.

DS over 3 years ago

@Rafi Benkual what are you using what-input.js for?

Rafa Sanchez about 3 years ago

In version 6, as long as you saved your additional file in src/assets/js, you will find the content of your file appended to the app.js file in the dist folder.

RCD over 2 years ago

I am trying to do the same thing and it wont work.

 

When adding my js file to the src/assets/js folder, I still get an error saying that my variable is not defined.

I tried adding the path to config.yml

I dont see a place to add it to the gulpfile.babel.js

 

Any advice is appreciated!

Daniel Molnar over 1 year ago

I also put custom .js files in the src/js folder and src/js/lib folders but they do not get compiled into the app.js file automatically.

Do we need to import our own files using ES2015 import commands by adding them into the app.js file under src/js/ ?

I have no idea how that would look since the path is different than .js files in the node_modules folder.

 

I'd prefer to compile everything into 1 file (dist/assets/app.js) and have it automatically minified to improve page load times by a few milliseconds ;-)

 

Thanks!

Daniel