mrapi
mrapi

Reputation: 6023

Can't build angular 4 project using systemjs

I'm using Angular 4 with VS 2017 (ASP 5 Web Api) +systemjs. I'm trying to build Angular application for production,I've added 2 dependencies in package.json

"devDependencies": {
    .....
    "gulp": "3.9.1",
    "systemjs-builder": "0.16.11"
  }

I've created create gulpfile.js in asp project root folder

var gulp = require('gulp'),
  Builder = require('systemjs-builder');


gulp.task('bundle-angular-dependencies', function() {
  // optional constructor options
  // sets the baseURL and loads the configuration file
  var builder = new Builder('', 'systemjs.config.js');

  return builder
    .bundle('app/boot.js - [app/**/*.js]', 'path/to/put/angular.bundle.js', { minify: true})
    .then(function() {
      console.log('Build complete');
    })
    .catch(function(err) {
      console.log('Build error');
      console.log(err);
    });
});

then in root folder of project I've run :

gulp bundle-angular-dependencies

and got

Build error
Error: Unable to calculate canonical name to bundle file:///app/boot.js. Ensure that this module sits within the baseURL or a wildcard path config.
    at getCanonicalNamePlain (D:\myapp\node_modules\systemjs-builder\lib\utils.js:227:13)
    at getCanonicalName (D:\myapp\node_modules\systemjs-builder\lib\utils.js:150:19)
    at D:\myapp\node_modules\systemjs-builder\lib\arithmetic.js:171:38
    at <anonymous>
[18:50:43] Finished 'bundle-angular-dependencies' after 604 ms

thanks for any help

Upvotes: 0

Views: 118

Answers (1)

DeborahK
DeborahK

Reputation: 60596

Why not use the new built-in Angular templates for Visual Studio 2017?

File | New | Project

Select the ASP.NET Core Web Application template

Then in the "New ASP.NET Core Web Application" dialog, select Angular.

enter image description here

Upvotes: 1

Related Questions