Open LvChengbin opened 6 years ago
Interesting. I didn't know Rollup supported arrays as configs now. I wonder how long it's been doing that.
For now, since you have just one item, you can just remove the square brackets:
import resolve from 'rollup-plugin-node-resolve';
export default {
input : 'src/znxy.js',
plugins : [
resolve( {
module : true,
jsnext : true
} )
],
output : [
{ file : 'dist/znxy.', format : 'umd', name : 'ZNXY' }
]
};
But I may want to look into supporting arrays. Thanks for bringing this to my attention.
Unfortunately, I encountered another problem after removing the square brackets. The rollup
plugin cannot work if it is running under rollup-stream
, I got TypeError: dest.write is not a function
, do I need more config items?
@LvChengbin Can I see your gulpfile?
This the code in gulpfile
, it was working well before with gulp-rollup
, but it doesn't support specifying a config file for rollup.
gulp.task( 'default', () => {
gulp.src( 'src/**/*.js' )
.pipe( createBuildDirectiveHandler( 'web' ) )
.pipe( rollup( 'rollup.config.js' ).on( 'error', errorhandler ) )
//.pipe( babel().on( 'error', errorhandler ) )
.pipe( replace( '@@API_HOST', settings.uri.api_host ) )
//.pipe( replace( '@@version', settings.version ) )
.pipe( replace( /@@template::([^\s<>'"]+)/ig, function( m, n ) {
const path = settings.src + '/templates/' + n;
if( !fs.existsSync( path ) ) {
console.log( `Template file ${path} is not existing` );
return m;
}
return fs.readFileSync( path ).toString().replace( /\s+/g, ' ' ).replace( /'/g, '\\\'' );
} ) )
.pipe( replace( /@@c\.([^\-\s<>'"]+)/ig, ( m, n ) => {
return settings.selectorPrefix[ n.toLowerCase() ];
} ) )
.pipe( replace( /@@images::/ig, settings.uri.images ) )
.pipe( gulp.dest( './sdk' ) );
} );
@LvChengbin rollup-stream isn't a drop-in replacement for gulp-rollup. Its API is different.
You should read the README. If you still have questions after that, you can ask here.
this is my code in
rollup.config.js
:It is working well if I run rollup with
rollup -c
.But if I run it in gulp with
rollup-stream
I would get this error message: