Skip to content

Commit

Permalink
update build script
Browse files Browse the repository at this point in the history
  • Loading branch information
zack24q committed Jul 28, 2017
1 parent 1a86ca3 commit 3ef16fb
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 95 deletions.
61 changes: 57 additions & 4 deletions build/build.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,61 @@
const version = require('../package.json').version
const fs = require('fs')
const rollup = require('rollup')
const config = require('./rollup.config.js')
const babel = require('rollup-plugin-babel')
const progress = require('rollup-plugin-progress')
const filesize = require('filesize')
const uglifyES = require('uglify-es')
const uglifyJS = require('uglify-js')

rollup.rollup(config.entry).then(bundle => {
config.bundles.map(value => {
bundle.write(value)
const banner = `/**
* vue-navigation v${version}
* https://github.com/zack24q/vue-navigation
* Released under the MIT License.
*/
`
const inputOptions = {
entry: 'src/index.js',
plugins: [babel(), progress()]
}
const uglifyOptions = () => {
return {
output: {
comments: true
}
}
}
const targets = [
{
name: 'vue-navigation.esm',
options: {
banner: banner,
format: 'es'
},
uglify: uglifyES
},
{
name: 'vue-navigation.umd',
options: {
banner: banner,
format: 'umd',
moduleName: 'VueNavigation'
},
uglify: uglifyJS
}
]

rollup.rollup(inputOptions).then(bundle => {
const size = code => filesize(Buffer.byteLength(code))
console.info('\nfiles size:')
targets.forEach(({name, options, uglify}) => {
const code = bundle.generate(options).code
console.info(`${name}.js ${size(code)}`)
fs.writeFileSync(`dist/${name}.js`, code, 'utf8')
const result = uglify.minify(code, uglifyOptions())
result.error && console.error(result.error)
console.info(`${name}.min.js ${size(result.code)}`)
fs.writeFileSync(`dist/${name}.min.js`, result.code, 'utf8')
})

console.info('\nbuild done.')
})
30 changes: 0 additions & 30 deletions build/rollup.config.js

This file was deleted.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@
"url": "https://github.com/zack24q/vue-navigation/issues"
},
"homepage": "https://github.com/zack24q/vue-navigation#readme",
"dependencies": {
"vue": "^2.2.4",
"vue-router": "^2.3.0",
"vuex": "^2.2.1"
},
"dependencies": {},
"devDependencies": {
"anywhere": "^1.4.0",
"autoprefixer": "^6.7.2",
Expand All @@ -57,6 +53,7 @@
"express": "^4.14.1",
"extract-text-webpack-plugin": "^2.0.0",
"file-loader": "^0.10.0",
"filesize": "^3.5.10",
"friendly-errors-webpack-plugin": "^1.1.3",
"function-bind": "^1.1.0",
"html-webpack-plugin": "^2.28.0",
Expand All @@ -68,13 +65,17 @@
"rimraf": "^2.6.0",
"rollup": "^0.41.6",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-filesize": "^1.2.1",
"rollup-plugin-progress": "^0.2.1",
"semver": "^5.3.0",
"uglify-es": "^3.0.26",
"uglify-js": "^3.0.26",
"url-loader": "^0.5.7",
"vue": "^2.4.2",
"vue-loader": "^11.1.4",
"vue-router": "^2.7.0",
"vue-style-loader": "^2.0.0",
"vue-template-compiler": "^2.2.4",
"vuex": "^2.3.1",
"webpack": "^2.2.1",
"webpack-bundle-analyzer": "^2.2.1",
"webpack-dev-middleware": "^1.10.0",
Expand Down
101 changes: 46 additions & 55 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ any-observable@^0.2.0:
resolved "https://registry.yarnpkg.com/any-observable/-/any-observable-0.2.0.tgz#c67870058003579009083f54ac0abafb5c33d242"

anymatch@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.0.tgz#a3e52fa39168c825ff57b0248126ce5a8ff95507"
version "1.3.2"
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.2.tgz#553dcb8f91e3c889845dfdba34c77721b90b9d7a"
dependencies:
arrify "^1.0.0"
micromatch "^2.1.5"
normalize-path "^2.0.0"

anywhere@^1.4.0:
version "1.4.0"
Expand Down Expand Up @@ -756,8 +756,8 @@ babel-register@^6.22.0, babel-register@^6.24.1:
source-map-support "^0.4.2"

babel-runtime@^6.18.0, babel-runtime@^6.22.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.23.0.tgz#0a9489f144de70efb3ce4300accdb329e2fc543b"
version "6.25.0"
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.25.0.tgz#33b98eaa5d482bb01a8d1aa6b437ad2b01aec41c"
dependencies:
core-js "^2.4.0"
regenerator-runtime "^0.10.0"
Expand Down Expand Up @@ -857,7 +857,7 @@ [email protected]:
dependencies:
hoek "2.x.x"

boxen@^1.0.0, boxen@^1.1.0:
boxen@^1.0.0:
version "1.2.1"
resolved "https://registry.yarnpkg.com/boxen/-/boxen-1.2.1.tgz#0f11e7fe344edb9397977fc13ede7f64d956481d"
dependencies:
Expand Down Expand Up @@ -1013,12 +1013,12 @@ caniuse-api@^1.5.2:
lodash.uniq "^4.5.0"

caniuse-db@^1.0.30000529, caniuse-db@^1.0.30000634, caniuse-db@^1.0.30000639:
version "1.0.30000704"
resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000704.tgz#8c5aa6fed8058e65c70f2c1f5d63f7088650705c"
version "1.0.30000708"
resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000708.tgz#c2e736bd3b7fc5f6c14e4c6dfe62b98ed15e8a5b"

caniuse-lite@^1.0.30000704:
version "1.0.30000704"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000704.tgz#adb6ea01134515663682db93abab291d4c02946b"
version "1.0.30000708"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000708.tgz#71dbf388c57f379b1bb66c89a890edc04c2509b6"

capture-stack-trace@^1.0.0:
version "1.0.0"
Expand Down Expand Up @@ -1188,7 +1188,7 @@ colormin@^1.0.5:
css-color-names "0.0.4"
has "^1.0.1"

colors@^1.1.2, colors@~1.1.2:
colors@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63"

Expand Down Expand Up @@ -1516,12 +1516,6 @@ decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2:
version "1.2.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"

deep-assign@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/deep-assign/-/deep-assign-2.0.0.tgz#ebe06b1f07f08dae597620e3dd1622f371a1c572"
dependencies:
is-obj "^1.0.0"

deep-extend@~0.4.0:
version "0.4.2"
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f"
Expand Down Expand Up @@ -1554,10 +1548,14 @@ [email protected]:
version "0.4.4"
resolved "https://registry.yarnpkg.com/depd/-/depd-0.4.4.tgz#07091fae75f97828d89b4a02a2d4778f0e7c0662"

[email protected], depd@~1.1.0:
[email protected]:
version "1.1.0"
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.0.tgz#e1bd82c6aab6ced965b97b88b17ed3e528ca18c3"

depd@~1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.1.tgz#5783b4e1c459f06fa5ca27f991f3d06e7a310359"

des.js@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/des.js/-/des.js-1.0.0.tgz#c074d2e2aa6a8a9a07dbd61f9a15c2cd83ec8ecc"
Expand Down Expand Up @@ -1701,13 +1699,13 @@ encodeurl@~1.0.1:
resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.1.tgz#79e3d58655346909fe6f0f45a5de68103b294d20"

enhanced-resolve@^3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-3.3.0.tgz#950964ecc7f0332a42321b673b38dc8ff15535b3"
version "3.4.1"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-3.4.1.tgz#0421e339fd71419b3da13d129b3979040230476e"
dependencies:
graceful-fs "^4.1.2"
memory-fs "^0.4.0"
object-assign "^4.0.1"
tapable "^0.2.5"
tapable "^0.2.7"

entities@~1.1.1:
version "1.1.1"
Expand Down Expand Up @@ -1916,7 +1914,7 @@ filename-regex@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26"

filesize@^3.5.6, filesize@^3.5.9:
filesize@^3.5.10, filesize@^3.5.9:
version "3.5.10"
resolved "https://registry.yarnpkg.com/filesize/-/filesize-3.5.10.tgz#fc8fa23ddb4ef9e5e0ab6e1e64f679a24a56761f"

Expand Down Expand Up @@ -2424,9 +2422,9 @@ invert-kv@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6"

ipaddr.js@1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.3.0.tgz#1e03a52fdad83a8bbb2b25cbf4998b4cffcd3dec"
ipaddr.js@1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.4.0.tgz#296aca878a821816e5b85d0a285a99bcff4582f0"

is-absolute-url@^2.0.0:
version "2.1.0"
Expand Down Expand Up @@ -2969,15 +2967,15 @@ miller-rabin@^4.0.0:
bn.js "^4.0.0"
brorand "^1.0.1"

mime-db@~1.27.0:
version "1.27.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.27.0.tgz#820f572296bbd20ec25ed55e5b5de869e5436eb1"
mime-db@~1.29.0:
version "1.29.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.29.0.tgz#48d26d235589651704ac5916ca06001914266878"

mime-types@^2.1.12, mime-types@~2.1.11, mime-types@~2.1.15, mime-types@~2.1.7:
version "2.1.15"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.15.tgz#a4ebf5064094569237b8cf70046776d09fc92aed"
version "2.1.16"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.16.tgz#2b858a52e5ecd516db897ac2be87487830698e23"
dependencies:
mime-db "~1.27.0"
mime-db "~1.29.0"

mime-types@~1.0.0:
version "1.0.2"
Expand Down Expand Up @@ -3137,7 +3135,7 @@ normalize-package-data@^2.3.2, normalize-package-data@^2.3.4:
semver "2 || 3 || 4 || 5"
validate-npm-package-license "^3.0.1"

normalize-path@^2.0.1:
normalize-path@^2.0.0, normalize-path@^2.0.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9"
dependencies:
Expand Down Expand Up @@ -3751,11 +3749,11 @@ proto-list@~1.2.1:
resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849"

proxy-addr@~1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-1.1.4.tgz#27e545f6960a44a627d9b44467e35c1b6b4ce2f3"
version "1.1.5"
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-1.1.5.tgz#71c0ee3b102de3f202f3b64f608d173fcba1a918"
dependencies:
forwarded "~0.1.0"
ipaddr.js "1.3.0"
ipaddr.js "1.4.0"

prr@~0.0.0:
version "0.0.0"
Expand Down Expand Up @@ -4096,16 +4094,6 @@ rollup-plugin-babel@^2.7.1:
object-assign "^4.1.0"
rollup-pluginutils "^1.5.0"

rollup-plugin-filesize@^1.2.1:
version "1.4.2"
resolved "https://registry.yarnpkg.com/rollup-plugin-filesize/-/rollup-plugin-filesize-1.4.2.tgz#eebdf571217e2fe14ab14a6534bf21f771a053b1"
dependencies:
boxen "^1.1.0"
colors "^1.1.2"
deep-assign "^2.0.0"
filesize "^3.5.6"
gzip-size "^3.0.0"

rollup-plugin-progress@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/rollup-plugin-progress/-/rollup-plugin-progress-0.2.1.tgz#e3c932a0316374daaf37f471c86d4adfb9caee57"
Expand Down Expand Up @@ -4172,11 +4160,7 @@ semver-diff@^2.0.0:
dependencies:
semver "^5.0.3"

"semver@2 || 3 || 4 || 5", semver@^5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"

semver@^5.0.3, semver@^5.1.0, semver@^5.2.0:
"semver@2 || 3 || 4 || 5", semver@^5.0.3, semver@^5.1.0, semver@^5.2.0, semver@^5.3.0:
version "5.4.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e"

Expand Down Expand Up @@ -4501,7 +4485,7 @@ symbol-observable@^1.0.1:
version "1.0.4"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.4.tgz#29bf615d4aa7121bdd898b22d4b3f9bc4e2aa03d"

tapable@^0.2.5, tapable@~0.2.5:
tapable@^0.2.7, tapable@~0.2.5:
version "0.2.7"
resolved "https://registry.yarnpkg.com/tapable/-/tapable-0.2.7.tgz#e46c0daacbb2b8a98b9b0cea0f4052105817ed5c"

Expand Down Expand Up @@ -4599,7 +4583,14 @@ type-is@~1.6.15:
media-typer "0.3.0"
mime-types "~2.1.15"

[email protected]:
uglify-es@^3.0.26:
version "3.0.26"
resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.0.26.tgz#0af5674aeb3325ce0cb1dd8746afd6b953f20798"
dependencies:
commander "~2.11.0"
source-map "~0.5.1"

[email protected], uglify-js@^3.0.26:
version "3.0.26"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.0.26.tgz#ba279ca597b13fe6c62c2d87dd5188e57a7a3233"
dependencies:
Expand Down Expand Up @@ -4770,7 +4761,7 @@ vue-loader@^11.1.4:
vue-style-loader "^2.0.0"
vue-template-es2015-compiler "^1.2.2"

vue-router@^2.3.0:
vue-router@^2.7.0:
version "2.7.0"
resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-2.7.0.tgz#16d424493aa51c3c8cce8b7c7210ea4c3a89aff1"

Expand All @@ -4792,11 +4783,11 @@ vue-template-es2015-compiler@^1.2.2:
version "1.5.3"
resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.5.3.tgz#22787de4e37ebd9339b74223bc467d1adee30545"

vue@^2.2.4:
vue@^2.4.2:
version "2.4.2"
resolved "https://registry.yarnpkg.com/vue/-/vue-2.4.2.tgz#a9855261f191c978cc0dc1150531b8d08149b58c"

vuex@^2.2.1:
vuex@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/vuex/-/vuex-2.3.1.tgz#cde8e997c1f9957719bc7dea154f9aa691d981a6"

Expand Down

0 comments on commit 3ef16fb

Please sign in to comment.