This repository has been archived by the owner on Dec 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17a2bbd
commit 78a2695
Showing
16 changed files
with
258 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,32 @@ | ||
import babel from 'rollup-plugin-babel'; | ||
import { terser } from 'rollup-plugin-terser'; | ||
import babel from 'rollup-plugin-babel' | ||
import MagicString from 'magic-string' | ||
|
||
export default { | ||
input: 'src/index.js', | ||
output: { file: 'index.js', format: 'cjs', sourcemap: true, strict: false }, | ||
output: { | ||
file: 'dist/index.js', | ||
format: 'cjs', | ||
sourcemap: true, | ||
strict: true, | ||
}, | ||
plugins: [ | ||
babel({ | ||
plugins: [ '@babel/syntax-dynamic-import' ], | ||
presets: [ ['@babel/env', { targets: { node: 8 } }] ] | ||
presets: [['@babel/env', { targets: { node: 10 } }]], | ||
}), | ||
terser(), | ||
addHashBang() | ||
] | ||
}; | ||
addHashBang(), | ||
], | ||
} | ||
|
||
function addHashBang () { | ||
function addHashBang() { | ||
return { | ||
name: 'add-hash-bang', | ||
renderChunk (code) { | ||
return `#!/usr/bin/env node\n${code}`; | ||
} | ||
}; | ||
renderChunk(code) { | ||
const str = new MagicString(code) | ||
str.prepend(`#!/usr/bin/env node\n`) | ||
return { | ||
code: str.toString(), | ||
map: str.generateMap({ hires: true }), | ||
} | ||
}, | ||
} | ||
} |
Oops, something went wrong.