我正在尝试使用Rollup从我的Angular 5应用程序构建Node模块。它似乎正确地构建了一切,但不知怎的,我无法在构建中找到我的应用程序css文件。这就是我在ng serve --aot
ERROR in : Couldn't resolve resource ./some.component.css relative to [my_app_path]/node_modules/my_node_module/app-body/some.component.d.ts
这是我的rollup.config.und.js
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import angular from 'rollup-plugin-angular';
import typescript from 'rollup-plugin-typescript';
import postcss from 'rollup-plugin-postcss';
var sass = require('node-sass');
import {nameLibrary,PATH_SRC,PATH_DIST} from './config-library.js';
export default {
entry: PATH_SRC+'index.ts',
format: 'umd',
moduleName: nameLibrary,
sourceMap:true,
external: [
'@angular/core',
...
],
dest:PATH_DIST+"index.umd.js",
plugins: [
angular({
preprocessors:{
template:template => template,
style: scss => {
let css;
if(scss){
css = sass.renderSync({data: scss}).css.toString();
//console.log( 'scss ', scss, 'css ', css );
}else{
css = '';
}
return css;
},
}
}),
typescript({
typescript:require('typescript')
}),
resolve({
module: true,
main: true
}),
commonjs({
include: 'node_modules/**',
})
],
onwarn: warning => {
const skip_codes = [
'THIS_IS_UNDEFINED',
'MISSING_GLOBAL_NAME'
];
if (skip_codes.indexOf(warning.code) != -1) return;
console.error(warning);
}
};
这是我的tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"sourceMap": true,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"declaration": true,
"outDir": "./dist",
"lib": ["es2016", "dom"]
},
"files": [
"src/index.ts"
],
"angularCompilerOptions": {
"skipTemplateCodegen": true
}
}
构建后,我在dist
文件夹中找到我的应用程序正确的结构,例如
some.component.d.ts
some.component.js
some.component.js.map
some.component.metadata.json
文件但没有
some.component.css
任何想法?提前谢谢。