aurelia / bundler

A library for bundling JavaScript, HTML and CSS for use with SystemJS.
MIT License
37 stars 25 forks source link

Bundling dist folder only #45

Closed dpinart closed 8 years ago

dpinart commented 8 years ago

Hi,

I'd like to create 2 bundles, one containing the app named app-bundle and the other one containing aurelia plugins and other libraries. I've created a bundle configuration as follows: var config


var config ={
     force: true,
     packagePath: '.',
    bundles:[
      "dist/app-bundle":{
         includes: [
         "*/**/*",
        "*/**/*.html!text",
        ],
      options:{
        inject: true,
        minify: false
      }
     },
    "dist/aurelia-bundle":{
       includes: [
       "jquery",
       "aurelia-framework",
      "aurelia-http-client",
       "aurelia-route-recognizer",
        'aurelia-task-queue',
        'aurelia-bootstrapper',
        'aurelia-http-client',
        'aurelia-router',
       blah, blah, blah,
       ],
      options: {
        inject: true,
        minify: true
      }
      }
]
}

I'd expect app-bundle containing only modules within the dist folder. However it seems it's bundling everything. I can see in the config.js file that app-bundle contains jquery, aurelia plugins and all the third party libs

EisenbergEffect commented 8 years ago

@ahmedshuhel We either need a bug fix or proper documentation on this...because we keep seeing this problem over and over again.

dpinart commented 8 years ago

Right now, I can live with a workaround for this. I'm facing other problems when bundling but not sure if it's an issue of the bundler or it's in the source code: 1) As you can see in above example, app-bundle includes "*/**/*" and "*/**/*" .html!text. Adding "*" and "*.html!text" causes the bundling process to hang out and it never ends 2)In my first attemp, I tried to create only one bundle minified. Apparently the bundle worked fine but when delpyed it, some routes/views didn't work fine. The app couldn't navigate to the route but nothing in console,... just the app didn't navigate to the required route. Surprisingly, if set minify to false then everything works as expected. That's why I'm creating 2 bundles, one with the dist/code without minify and another one with the libs minified (bundlng only the libs minified works fine too)

BBosman commented 8 years ago

I've "fixed" this in my project by putting the same content as the dist/aurelia-bundle includes property in the excludes property for dist/app-bundle.

ahmedshuhel commented 8 years ago

That is one of the ways to solve it. Another ways is to include like ["*/**/*"] :

var config ={
     force: true,
     packagePath: '.',
    bundles:[
      "dist/app-bundle":{
         includes: [
         ["*/**/*"],
        "*/**/*.html!text",
        ],
      options:{
        inject: true,
        minify: false
      }
     },

This will automatically exclude the dependencies from the first bundle.

ahmedshuhel commented 8 years ago

There are some docs available here that touches this issue. Please read the Duplicate Modules in Multiple Bundles section for more details.