Aurelia bundler不会删除对旧版本捆绑包的引用

时间:2016-10-25 10:02:27

标签: javascript aurelia aurelia-framework aurelia-bundling

我正在将我的SPA网络应用程序从Durandal切换到Aurelia,现在我正在查看捆绑过程。

我使用gulp捆绑应用程序,然后按照this Aurelia documentation page上的说明和网络上的其他资源进行操作。它有效,但对我来说还有一些不清楚的事情。

这是我的gulpfile.js

var gulp = require('gulp'),
    bundler = require('aurelia-bundler'),
    uglify = require('gulp-uglify'),
    htmlmin = require('gulp-htmlmin'),    
    del = require('del');

var config = {    
    force: true,    
    baseURL: '.',                   // baseURL of the application
    configPath: './config.js',      // config.js file. Must be within `baseURL`
    bundles: {
        "Scripts/build/app-build": {           // bundle name/path. Must be within `baseURL`. Final path is: `baseURL/dist/app-build.js`.
            includes: [                
              '[Scripts/app/**/*.js]',
              'Scripts/app/**/*.html!text',
              'Content/*.css!text'
            ],            
            options: {
                inject: true,
                minify: true,
                depCache: true,
                rev: true                
            }
        },
        "Scripts/build/vendor-build": {
            includes: [
                'jspm_packages/npm/babel-runtime@5.8.38/helpers/class-call-check.js',
                'jspm_packages/npm/babel-runtime@5.8.38/helpers/create-class.js',
                'jspm_packages/npm/babel-runtime@5.8.38/core-js/object/define-property.js',
                'jspm_packages/npm/core-js@1.2.7/library/fn/object/define-property.js',
                'jspm_packages/npm/babel-runtime@5.8.38/core-js/object/define-properties.js',
                'jspm_packages/npm/core-js@1.2.7/library/fn/object/define-properties.js',
                'npm:aurelia-framework@1.0.7',                
                'npm:aurelia-loader-default@1.0.0',
                'npm:aurelia-logging-console@1.0.0',
                'npm:aurelia-templating-binding@1.0.0',
                'npm:aurelia-templating-resources@1.1.1',
                'npm:aurelia-templating-router@1.0.0',
                'npm:aurelia-knockout@1.0.2',
                'npm:aurelia-history-browser@1.0.0',
                'npm:aurelia-bootstrapper@1.0.0',
                'npm:aurelia-fetch-client@1.0.1',
                'npm:aurelia-router@1.0.6',
                'npm:aurelia-animator-css@1.0.1',
                'npm:babel-core@5.8.38',
                'npm:babel-runtime@5.8.38',
                'npm:core-js@1.2.7',
                'github:systemjs/plugin-text@0.0.9'
            ],
            options: {
                inject: true,
                minify: true,
                depCache: true,
                rev: true                
            }
        }
    }
};

gulp.task('build', ['minify'], function () {
    return bundler.bundle(config);
});

这是config.js

System.config({
  baseURL: "/",
  defaultJSExtensions: true,
  transpiler: "babel",
  babelOptions: {
    "optional": [
      "es7.decorators",
      "es7.classProperties",
      "runtime"
    ],
    "compact": true
  },
  paths: {
    "github:*": "jspm_packages/github/*",
    "npm:*": "jspm_packages/npm/*"
  },
  bundles: {

  },
map: //some mappings
}

如果我运行gulp任务进行捆绑,它可以工作,我可以使用捆绑的文件加载我的应用程序,但有一些我不明白的事情:

创建捆绑文件后,config.js文件在“bundles:”属性中更新,其中包含为捆绑创建的文件和随机版本号(因为我设置了'rev:true'在选项中)

bundles: [
    "Scripts/build/vendor-build-4c2789cace.js": [
        //list of files
    ]
]

当我再次运行任务时,也许经过一些更改后,新的捆绑文件已添加到config.js文件中:

bundles: [
    "Scripts/build/vendor-build-4c2789cace.js": [
        //list of files
    ],
    "Scripts/build/vendor-build-t67uj8e5f4.js": [
        //list of files
    ]
]

但是你可以看到,旧的还在那里。在创建新捆绑包时,如何告诉他“清除”捆绑包属性?

0 个答案:

没有答案