I am trying to bundle my Angular2 app using RollupJS but I have been running into a few issues:
- The css file referenced by my AppComponent couldn't be found and throws an error.
Error transforming /demo-app.ts with 'angular' plugin: ENOENT: no such file or directory, open /demo-app.css
To fix this I wrote a gulp task to compile my scss files to css. But I was under the impression that Rollup was able to do this.
- An rxjs module is causing me errors.
Module /node_modules/rxjs/observable/of.js does not export of (imported by /@angular/router/src/apply_redirects.js)
I have tried to use rollup-plugin-alias and writing a specific resolveRxJS function to fix this but no luck.
const babel = require('rollup-plugin-babel');
const eslint = require('rollup-plugin-eslint');
const commonjs = require('rollup-plugin-commonjs');
const typescript = require('rollup-plugin-typescript');
const angular = require('rollup-plugin-angular');
const alias = require('rollup-plugin-alias');
const resolve = require('rollup-plugin-node-resolve');
const progress = require('rollup-plugin-progress');
const postcss = require('rollup-plugin-postcss');
export default {
entry: 'src/demo-app/main.ts',
dest: 'dist/demo-app/bundle.min.js',
format: 'iife',
sourceMap: 'inline',
plugins: [
{
resolveRxJS: id => {
if (id.startsWith('rxjs/') || id.startsWith('rxjs\\')) {
let result = `${__dirname}/node_modules/rxjs-es/${id.replace('rxjs/', '')}.js`;
return result.replace(/\//g, "\\");
}
}
},
angular(),
typescript({
typescript: require('typescript'),
tsconfig: tsOptions
}),
//alias({
// rxjs: __dirname + '/node_modules/rxjs'
//}),
babel({
exclude: '/node_modules/**',
include: '/node_modules/tslint-no-unused-var/**',
// include: '/node_modules/rxjs/**'
}),
resolve({
module: true,
jsnext: true
}),
]
}
The commented out code is other things I have tried. note: I have also tried using preprocessors in the rollup-plugin-angular function which also didn't compile my css.
So to recap 1) do I always have to compile my scss files with gulp before running the rollup code? 2) How do I fix the rxjs module issue?
Thanks