forked from parcel-bundler/parcel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minify prelude.js (parcel-bundler#431)
* run prettier * minify * fix linting issues
- Loading branch information
1 parent
08b321e
commit 534399e
Showing
6 changed files
with
64 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,5 +16,6 @@ lib | |
dist | ||
/test/dist | ||
/test/input | ||
minified | ||
|
||
coverage |
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 |
---|---|---|
|
@@ -11,3 +11,4 @@ lib | |
!test/**/node_modules | ||
.vscode/ | ||
.idea/ | ||
minified/ |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const uglify = require('uglify-es'); | ||
const fs = require('./src/utils/fs'); | ||
const path = require('path'); | ||
|
||
async function minify(inputPath, outputPath) { | ||
let input = (await fs.readFile(inputPath)).toString(); | ||
|
||
// Minify input | ||
let options = { | ||
mangle: { | ||
toplevel: true | ||
}, | ||
output: { | ||
ecma: 3, | ||
semicolons: false | ||
} | ||
}; | ||
let res = uglify.minify(input, options); | ||
|
||
// Write output | ||
await fs.mkdirp(path.dirname(outputPath)); | ||
await fs.writeFile(outputPath, res.code); | ||
} | ||
|
||
async function runMinifier() { | ||
let files = ['prelude.js']; | ||
|
||
files.forEach(async file => { | ||
await minify( | ||
path.join('./src/builtins/', file), | ||
path.join('./minified/builtins/', file) | ||
); | ||
// eslint-disable-next-line no-console | ||
console.log('minified: ' + file); | ||
return; | ||
}); | ||
} | ||
|
||
(async () => { | ||
await runMinifier(); | ||
})(); |
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