Skip to content

How do I use a 3rd party lib required by a script tag in the html file? #1171

Closed
abhiit89/angular-cli
#13
@NullVoxPopuli

Description

@NullVoxPopuli

I've given up with imports/requires, so I am trying the script-tag way.

in src/index.html:

  {{#unless environment.production}}
  <!-- These two files (used for testing) cannot be included the 'normal' way,
  because angular-cli's build tools don't resolve dependencies of 3rd party libs. -->
  <script src="/dist/vendor/sinon/pkg/sinon.js" type="text/javascript"></script>
  <script src="/dist/vendor/axios/dist/axios.js" type="text/javascript"></script>
  {{/unless}}
</head>

and in angular-cli-build.js:

    vendorNpmFiles: [
     ...
      'sinon/**/*.js',
    ],

and then in my test:

declare var sinon:any;
...
  beforeEach(() => sandbox = sinon.sandbox.create());

I get the error:

     ReferenceError: sinon is not defined

$ ng --version
angular-cli: 1.0.0-beta.6
node: 5.10.1
os: linux x64

how do I use the library?

after running ng test, there are 0 console errors in the opened chrome window. The errors are only in the terminal.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions