-
Notifications
You must be signed in to change notification settings - Fork 871
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #212 from yugasun/fix/silent-nouse-bug
Feat: add silent option for debug & update devDependencies
- Loading branch information
Showing
7 changed files
with
356 additions
and
347 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"presets": [ | ||
["es2015", { "modules": false }] | ||
["env", { "modules": false }] | ||
] | ||
} |
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,54 +1,65 @@ | ||
var fs = require('fs') | ||
var path = require('path') | ||
var rollup = require('rollup') | ||
var babel = require('rollup-plugin-babel') | ||
var uglify = require('rollup-plugin-uglify') | ||
var version = process.env.VERSION || require('./package.json').version | ||
|
||
var banner = | ||
'/*!\n' + | ||
' * Vue-Lazyload.js v' + version + '\n' + | ||
' * (c) ' + new Date().getFullYear() + ' Awe <[email protected]>\n' + | ||
' * Released under the MIT License.\n' + | ||
' */\n' | ||
|
||
rollup.rollup({ | ||
entry: path.resolve(__dirname, 'src/index.js'), | ||
plugins: [ | ||
babel(), | ||
uglify() | ||
] | ||
}) | ||
.then(bundle => { | ||
return write(path.resolve(__dirname, 'vue-lazyload.js'), rewriteVersion(bundle.generate({ | ||
format: 'umd', | ||
moduleName: 'VueLazyload' | ||
}).code)) | ||
}) | ||
.then(() => { | ||
console.log('Vue-Lazyload.js v' + version + ' builded') | ||
}) | ||
.catch(console.log) | ||
|
||
function rewriteVersion (code) { | ||
return code.replace('__VUE_LAZYLOAD_VERSION__', version) | ||
const fs = require('fs') | ||
const path = require('path') | ||
const rollup = require('rollup') | ||
const babel = require('rollup-plugin-babel') | ||
const uglify = require('rollup-plugin-uglify') | ||
const version = process.env.VERSION || require('./package.json').version | ||
|
||
const banner = | ||
'/*!\n' + | ||
' * Vue-Lazyload.js v' + version + '\n' + | ||
' * (c) ' + new Date().getFullYear() + ' Awe <[email protected]>\n' + | ||
' * Released under the MIT License.\n' + | ||
' */\n' | ||
async function build() { | ||
try { | ||
const bundle = await rollup.rollup({ | ||
input: path.resolve(__dirname, 'src/index.js'), | ||
plugins: [ | ||
babel({ | ||
exclude: 'node_modules/**', | ||
plugins: ['external-helpers'] | ||
}), | ||
uglify() | ||
] | ||
}) | ||
|
||
let { code } = await bundle.generate({ | ||
format: 'umd', | ||
name: 'VueLazyload' | ||
}) | ||
|
||
code = rewriteVersion(code) | ||
|
||
await write(path.resolve(__dirname, 'vue-lazyload.js'), code) | ||
|
||
console.log('Vue-Lazyload.js v' + version + ' builded') | ||
} catch (e) { | ||
console.log(e) | ||
} | ||
} | ||
|
||
function rewriteVersion(code) { | ||
return code.replace('__VUE_LAZYLOAD_VERSION__', version) | ||
} | ||
|
||
function getSize (code) { | ||
return (code.length / 1024).toFixed(2) + 'kb' | ||
function getSize(code) { | ||
return (code.length / 1024).toFixed(2) + 'kb' | ||
} | ||
|
||
function blue (str) { | ||
return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m' | ||
function blue(str) { | ||
return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m' | ||
} | ||
|
||
function write (dest, code) { | ||
return new Promise(function (resolve, reject) { | ||
code = banner + code | ||
fs.writeFile(dest, code, function (err) { | ||
if (err) return reject(err) | ||
console.log(blue(dest) + ' ' + getSize(code)) | ||
resolve() | ||
function write(dest, code) { | ||
return new Promise(function (resolve, reject) { | ||
code = banner + code | ||
fs.writeFile(dest, code, function (err) { | ||
if (err) return reject(err) | ||
console.log(blue(dest) + ' ' + getSize(code)) | ||
resolve() | ||
}) | ||
}) | ||
}) | ||
} | ||
|
||
build() |
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
Oops, something went wrong.