vigetlabs / blendid

A delicious blend of gulp tasks combined into a configurable asset pipeline and static site builder
MIT License
4.97k stars 682 forks source link

Build two javascript files #489

Closed icandeveloper closed 7 years ago

icandeveloper commented 7 years ago

I would like to build two separate javascript files, one called app.js that will have my websites general JS and another called navigation-only.js that will be used in a separate standalone part of the application.

In my task-config.js file I have updated the config to have both app and navigation-only but this is still compiling a single app.js. Even when I remove app.js it compiles it as app.js instead of navigation. The navigation code is included in that file though. How would I separate them into different files for inclusion?

  javascripts: {
    entry: {
      // files paths are relative to
      // javascripts.dest in path-config.json
      app: ["./app.js", "./navigation-only.js"]
    },
    // This tells webpack middleware where to
    // serve js files from in development:
    publicPath: "/assets/javascripts"
  },

Thanks

kennethwyu commented 7 years ago

See the following snippet on how to generate multiple JS files -- they'll end up in your dist with the appropriate name:

javascripts: {
    entry: {
      // files paths are relative to
      // javascripts.dest in path-config.json
      app: ["./app.js"],
      navigation-only: ["./navigation-only.js"],
      another-js-file: ["./js1.js", "./js2.js"]
    },
    // This tells webpack middleware where to
    // serve js files from in development:
    publicPath: "/assets/javascripts"
  },
icandeveloper commented 7 years ago

Thanks @kennethwyu, that worked. Just had to remove the "-" in the name.