If you want to use external HTML templates and CSS styles (or even SCSS styles) you might inline them first before NGC compilation by using Gulp and 'gulp-inline-ng2-template' plugin.

Here is how you npm scripts may look like in package.json:
{
"scripts": {
...
"build:esm": "gulp inline-templates && npm run ngcompile",
"ngcompile": "node_modules/.bin/ngc -p tsconfig-aot.json",
...
}
}
Then gulpfile.js would look like.
const gulp = require('gulp');
const sass = require('node-sass');
const inlineTemplates = require('gulp-inline-ng2-template');
/**
* Inline templates configuration.
* @see https://github.com/ludohenin/gulp-inline-ng2-template
*/
const INLINE_TEMPLATES = {
SRC: './src/**/*.ts',
DIST: './tmp/src-inlined',
CONFIG: {
base: '/src',
target: 'es6',
useRelativePaths: true,
styleProcessor: compileSass
}
};
/**
* Inline external HTML and SCSS templates into Angular component files.
* @see: https://github.com/ludohenin/gulp-inline-ng2-template
*/
gulp.task('inline-templates', () => {
return gulp.src(INLINE_TEMPLATES.SRC)
.pipe(inlineTemplates(INLINE_TEMPLATES.CONFIG))
.pipe(gulp.dest(INLINE_TEMPLATES.DIST));
});
/**
* Compile SASS to CSS.
* @see https://github.com/ludohenin/gulp-inline-ng2-template
* @see https://github.com/sass/node-sass
*/
function compileSass(path, ext, file, callback) {
let compiledCss = sass.renderSync({
data: file,
outputStyle: 'compressed',
});
callback(null, compiledCss.css);
}
This approach is utilized by angular-library-seed. You may look there for full integration example.
templateUrlandstyleUrlswith a similar outcome.