Gulp构建文件夹将angular-dynamic-locale脚本标记放置在角度脚本标记之上

时间:2017-02-02 00:12:28

标签: javascript angularjs gulp bower gulp-concat

我正在尝试在我的应用程序中运行angular-dynamic-locale但是在动态语言环境文件中不断收到错误“Angular is undefined”,因为构建将angular-dynamic-locale放在angular上面:

在build / debug / sandbox / index.html中:

<script src="../../../bower_components/angular-dynamic-locale/src/tmhDynamicLocale.js"></script>
<script src="../../../bower_components/angular/angular.js"></script>
<script src="../../../bower_components/angular-animate/angular-animate.js"></script>
<script src="../../../bower_components/angular-cookies/angular-cookies.js"></script>
<script src="../../../bower_components/angular-resource/angular-resource.js"></script>
<script src="../../../bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="../../../bower_components/angular-ui-router/release/angular-ui-router.js"></script>
<script src="../../../bower_components/angular-messages/angular-messages.js"></script>
<script src="../../../bower_components/ui-router-extras/release/ct-ui-router-extras.js"></script>
<script src="../../../bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="../../../bower_components/angular-translate/angular-translate.js"></script>
<script src="../../../bower_components/angular-translate-handler-log/angular-translate-handler-log.js"></script>
<script src="../../../bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.js"></script>
<script src="../../../bower_components/angular-translate-storage-cookie/angular-translate-storage-cookie.js"></script>
<script src="../../../bower_components/angular-translate-storage-local/angular-translate-storage-local.js"></script>
<script src="../../../bower_components/angular-mocks/angular-mocks.js"></script>

我的bower.json是项目的根,看起来像这样,一切都在这里建立:

"dependencies": {
  "angular": "1.5.8",
  "angular-animate": "1.5.8",
  "angular-cookies": "1.5.8",
  "angular-resource": "1.5.8",
  "angular-sanitize": "1.5.8",
  "angular-ui-router": "0.2.18",
  "angular-messages": "1.5.8",
  "angular-translate": "~2.13.1",
  "angular-translate-handler-log": "~2.13.1",
  "angular-translate-loader-static-files": "~2.13.1",
  "angular-translate-storage-cookie": "~2.13.1",
  "angular-translate-storage-local": "~2.13.1",
  "angular-dynamic-locale": "~0.1.32",
  "angular-i18n": "~1.6.1"
 }

除了angular-dynamic-locale之外,上面的所有依赖项都放在angular标记之下。我不知道为什么......

我的gulpfile:

['dist', 'debug'].forEach(function(targetedDistribution){

  gulp.task('sandbox:' + targetedDistribution + ':inject:' + theme, function() {

  var jsSandboxFiles = [
    'build/' + targetedDistribution + '/sandbox/**/*.js',
    'build/' + targetedDistribution + '/sandbox/**/*.css',
    'build/' + targetedDistribution + '/components/themes/' + theme +'/**/*.*'
    ];

  var jsSandboxSources = gulp.src(jsSandboxFiles, {read:false});

  var bowerFilesToInject = gulp.src(bowerFiles({includeDev:true}),{read:false})
    .pipe(filter(['*', '!**/jasmine**']));

  if(targetedDistribution === 'debug'){

    var jsComponentFiles = [
      'build/debug/components/**/' + bowerOpts.name + '-tpls.js'
    ];

    var orderedComponentsJS = require(path.join(__dirname,'..','build','debug','components','file-order'));
    jsComponentFiles = jsComponentFiles.concat(orderedComponentsJS);

    var jsComponentSources = gulp.src(jsComponentFiles, {read:false});
    return gulp
      .src('build/debug/sandbox/index.html')
      .pipe(inject(bowerFilesToInject,{name:'bower',relative:true}))
      .pipe(inject(jsComponentSources, {name:'components',relative:true}))
      .pipe(inject(jsSandboxSources, {name:'sandbox',relative:true}))
      .pipe(gulp.dest('build/debug/sandbox'));
  }else{
    var componentsFilesToInject = gulp.src("build/dist/components/ers-ui-components-with-tpls.min.js",{read:false});
    return gulp.src("build/dist/sandbox/index.html")
      .pipe(inject(bowerFilesToInject,{name:'bower',relative:true}))
      .pipe(inject(componentsFilesToInject,{name:'components',relative:true}))
      .pipe(inject(gulp.src(["build/dist/sandbox/**/*.js","build/dist/sandbox/**/*.css"], {read:false}), {name:'sandbox',relative:true}))
      .pipe(gulp.dest("build/dist/sandbox"));
  }
});

});

0 个答案:

没有答案