mirror of https://github.com/lukechilds/rollup.git
Rich Harris
9 years ago
8 changed files with 78 additions and 69 deletions
@ -1,57 +0,0 @@ |
|||
var gobble = require( 'gobble' ); |
|||
var fs = require( 'fs' ); |
|||
|
|||
var version = require( './package.json' ).version; |
|||
var commitHash = (function () { |
|||
try { |
|||
return fs.readFileSync( '.commithash', 'utf-8' ); |
|||
} catch ( err ) { |
|||
return 'unknown'; |
|||
} |
|||
})(); |
|||
|
|||
var banner = fs.readFileSync( 'src/banner.js' ).toString() |
|||
.replace( '${version}', version ) |
|||
.replace( '${time}', new Date() ) |
|||
.replace( '${commitHash}', commitHash ); |
|||
|
|||
var src = gobble( 'src' ); |
|||
|
|||
var node = src |
|||
.transform( 'rollup-babel', { |
|||
entry: 'rollup.js', |
|||
dest: 'rollup.js', |
|||
format: 'cjs', |
|||
external: [ 'fs' ], |
|||
sourceMap: true, |
|||
banner: banner, |
|||
load: function ( id ) { |
|||
if ( ~id.indexOf( 'rollup.js' ) ) { |
|||
return fs.readFileSync( 'src/rollup.js', 'utf-8' ).replace( /<@VERSION@>/, version ); |
|||
} |
|||
} |
|||
}); |
|||
|
|||
var browserPlaceholders = { |
|||
fs: fs.readFileSync( 'browser/fs.js' ).toString(), |
|||
promise: fs.readFileSync( 'browser/promise.js' ).toString() |
|||
}; |
|||
|
|||
var browser = src |
|||
.transform( 'rollup-babel', { |
|||
entry: 'rollup.js', |
|||
dest: 'rollup.browser.js', |
|||
format: 'umd', |
|||
moduleName: 'rollup', |
|||
sourceMap: true, |
|||
banner: banner, |
|||
load: function ( id ) { |
|||
if ( ~id.indexOf( 'rollup.js' ) ) { |
|||
return fs.readFileSync( 'src/rollup.js', 'utf-8' ).replace( /<@VERSION@>/, version ); |
|||
} |
|||
if ( ~id.indexOf( 'fs.js' ) ) return browserPlaceholders.fs; |
|||
if ( ~id.indexOf( 'es6-promise' ) ) return browserPlaceholders.promise; |
|||
} |
|||
}); |
|||
|
|||
module.exports = gobble([ node, browser ]); |
@ -0,0 +1,12 @@ |
|||
import config from './rollup.config.js'; |
|||
|
|||
config.plugins.push({ |
|||
load: function ( id ) { |
|||
if ( ~id.indexOf( 'fs.js' ) ) return readFileSync( 'browser/fs.js' ).toString(); |
|||
if ( ~id.indexOf( 'es6-promise' ) ) return readFileSync( 'browser/promise.js' ).toString(); |
|||
} |
|||
}); |
|||
|
|||
config.format = 'umd'; |
|||
|
|||
export default config; |
@ -0,0 +1,43 @@ |
|||
import { readFileSync } from 'fs'; |
|||
import babel from 'rollup-plugin-babel'; |
|||
import npm from 'rollup-plugin-npm'; |
|||
import replace from 'rollup-plugin-replace'; |
|||
|
|||
var pkg = JSON.parse( readFileSync( 'package.json', 'utf-8' ) ); |
|||
|
|||
var commitHash = (function () { |
|||
try { |
|||
return readFileSync( '.commithash', 'utf-8' ); |
|||
} catch ( err ) { |
|||
return 'unknown'; |
|||
} |
|||
})(); |
|||
|
|||
var banner = readFileSync( 'src/banner.js', 'utf-8' ) |
|||
.replace( '${version}', pkg.version ) |
|||
.replace( '${time}', new Date() ) |
|||
.replace( '${commitHash}', commitHash ); |
|||
|
|||
export default { |
|||
entry: 'src/rollup.js', |
|||
format: 'cjs', |
|||
plugins: [ |
|||
babel({ |
|||
//include: [ 'src/**', 'node_modules/acorn/**' ]
|
|||
}), |
|||
|
|||
npm({ |
|||
jsnext: true |
|||
}), |
|||
|
|||
replace({ |
|||
include: 'src/rollup.js', |
|||
delimiters: [ '<@', '@>' ], |
|||
sourceMap: true, |
|||
values: { 'VERSION': pkg.version } |
|||
}) |
|||
], |
|||
external: [ 'fs' ], |
|||
banner: banner, |
|||
sourceMap: true |
|||
}; |
Loading…
Reference in new issue