-
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.
[build] build script with rollup, build style with gulp
- Loading branch information
Showing
26 changed files
with
603 additions
and
111 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,12 @@ | ||
{ | ||
"presets": ["es2015", "stage-2"], | ||
"plugins": ["transform-runtime"], | ||
"comments": false | ||
"env": { | ||
"development": { | ||
"presets": ["es2015", "stage-2"], | ||
"comments": false | ||
}, | ||
"production": { | ||
"presets": ["es2015-rollup"], | ||
"comments": false | ||
} | ||
} | ||
} |
File renamed without changes.
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,26 @@ | ||
var gulp = require('gulp') | ||
var less = require('gulp-less') | ||
var banner = require('gulp-banner') | ||
var rename = require('gulp-rename') | ||
var LessAutoprefix = require('less-plugin-autoprefix') | ||
|
||
var autoprefix = new LessAutoprefix({ browsers: ['last 2 versions'] }) | ||
var pkg = require('../package.json') | ||
var comment = | ||
'/*!\n' + | ||
' * Pandora UI v <%= pkg.version %>' + '\n' + | ||
' * (c) ' + new Date().getFullYear() + ' <%= pkg.author %>\n' + | ||
' * Released under the MIT License.\n' + | ||
' */\n' | ||
|
||
gulp.task('less', function () { | ||
return gulp.src('./src/style/index.less') | ||
.pipe(banner(comment, {pkg: pkg})) | ||
.pipe(less({ | ||
plugins: [autoprefix] | ||
})) | ||
.pipe(rename('pandora-ui.css')) | ||
.pipe(gulp.dest('./dist')) | ||
}) | ||
|
||
gulp.start('less') |
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,162 @@ | ||
process.env.BABEL_ENV = 'production' | ||
|
||
var fs = require('fs') | ||
var path = require('path') | ||
var zlib = require('zlib') | ||
var rollup = require('rollup') | ||
var uglify = require('uglify-js') | ||
var buble = require('rollup-plugin-buble') | ||
var string = require('rollup-plugin-string') | ||
var vue = require('rollup-plugin-vue') | ||
var version = process.env.VERSION || require('../package.json').version | ||
var banner = | ||
'/*!\n' + | ||
' * Pandora UI v' + version + '\n' + | ||
' * (c) ' + new Date().getFullYear() + ' Lynzz\n' + | ||
' * Released under the MIT License.\n' + | ||
' */' | ||
var vueConfig = { | ||
compileTemplate: true, | ||
htmlMinifier: {collapseBooleanAttributes: false} | ||
} | ||
// var babelConfig = { | ||
// exclude: 'node_modules/**' | ||
// } | ||
var stringConfig = { | ||
include: ['**/*.svg', '**/*.html'] | ||
} | ||
var external = [ | ||
'async-validator' | ||
// 'moment', | ||
// 'velocity-animate' | ||
] | ||
var globals = { | ||
'async-validator': 'AsyncValidator' | ||
// moment: 'moment', | ||
// 'velocity-animate': 'Velocity' | ||
} | ||
var rollupConfig = { | ||
entry: 'src/index.js', | ||
plugins: [ | ||
vue(vueConfig), | ||
string(stringConfig), | ||
buble()], | ||
external: external | ||
} | ||
|
||
var file = fs | ||
.readFileSync('src/index.js', 'utf-8') | ||
.replace(/version: '[\d\.]+'/, "version: '" + version + "'") | ||
|
||
fs.writeFileSync('src/index.js', file) | ||
|
||
// CommonJS build. | ||
rollup | ||
.rollup(rollupConfig) | ||
.then(function (bundle) { | ||
return write('dist/pandora-ui.common.js', bundle.generate({ | ||
format: 'cjs', | ||
banner: banner, | ||
globals: globals, | ||
useStrict: false | ||
}).code) | ||
}) | ||
// ES6 Dev Build | ||
.then(function () { | ||
return rollup | ||
.rollup({ | ||
entry: 'src/index.js', | ||
plugins: [vue(vueConfig), string(stringConfig)], | ||
external: external | ||
}) | ||
.then(function (bundle) { | ||
return write('dist/pandora-ui.js', bundle.generate({ | ||
exports: 'named', | ||
banner: banner, | ||
globals: globals, | ||
useStrict: false | ||
}).code) | ||
}) | ||
}) | ||
// Standalone Dev Build | ||
.then(function () { | ||
return rollup.rollup(rollupConfig) | ||
.then(function (bundle) { | ||
return write('dist/pandora-ui.standalone.js', bundle.generate({ | ||
format: 'umd', | ||
banner: banner, | ||
moduleName: 'PandoraUI', | ||
globals: globals, | ||
useStrict: false | ||
}).code) | ||
}) | ||
}) | ||
// Standalone Production Build | ||
.then(function () { | ||
return rollup.rollup(rollupConfig) | ||
.then(function (bundle) { | ||
var code, res, map | ||
|
||
code = bundle.generate({ | ||
format: 'umd', | ||
moduleName: 'PandoraUI', | ||
banner: banner, | ||
globals: globals, | ||
useStrict: false | ||
}).code | ||
|
||
res = uglify.minify(code, { | ||
fromString: true, | ||
outSourceMap: 'pandora-ui.standalone.min.js.map', | ||
output: { | ||
preamble: banner, | ||
ascii_only: true | ||
} | ||
}) | ||
|
||
// fix uglifyjs sourcemap | ||
map = JSON.parse(res.map) | ||
map.sources = ['pandora-ui.standalone.js'] | ||
map.sourcesContent = [code] | ||
map.file = 'pandora-ui.standalone.min.js' | ||
|
||
return [ | ||
write('dist/pandora-ui.standalone.min.js', res.code), | ||
write('dist/pandora-ui.standalone.min.js.map', JSON.stringify(map)) | ||
] | ||
}) | ||
.then(zip) | ||
}) | ||
.catch(function (e) { | ||
console.log(e) | ||
}) | ||
|
||
function write (dest, code) { | ||
return new Promise(function (resolve, reject) { | ||
fs.writeFile(dest, code, function (err) { | ||
if (err) return reject(err) | ||
console.log(blue(path.relative(process.cwd(), dest)) + ' ' + getSize(code)) | ||
resolve() | ||
}) | ||
}) | ||
} | ||
|
||
function zip () { | ||
return new Promise(function (resolve, reject) { | ||
fs.readFile('dist/pandora-ui.standalone.min.js', function (err, buf) { | ||
if (err) return reject(err) | ||
zlib.gzip(buf, function (err, buf) { | ||
if (err) return reject(err) | ||
write('dist/pandora-ui.standalone.min.js.gz', buf).then(resolve) | ||
}) | ||
}) | ||
}) | ||
} | ||
|
||
function getSize (code) { | ||
return (code.length / 1024).toFixed(2) + 'kb' | ||
} | ||
|
||
function blue (str) { | ||
return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m' | ||
} |
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,34 @@ | ||
BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
if [ "$BRANCH" == "master" ] | ||
then | ||
TAG="latest" | ||
else | ||
TAG="$BRANCH" | ||
fi | ||
|
||
set -e | ||
echo "Enter release version @$TAG: " | ||
read VERSION | ||
|
||
read -p "Deploy $VERSION@$TAG - are you sure? (y/n)" -n 1 -r | ||
echo | ||
if [[ $REPLY =~ ^[Yy]$ ]] | ||
then | ||
echo "Deploying $VERSION@$TAG ..." | ||
|
||
# lint and test | ||
npm run lint 2>/dev/null | ||
|
||
# build | ||
VERSION=$VERSION npm run build | ||
|
||
# commit | ||
git add -A | ||
git commit -m "[build] $VERSION" | ||
npm version $VERSION --message "[release] $VERSION" | ||
|
||
# publish | ||
git push origin refs/tags/v$VERSION | ||
git push | ||
npm publish --tag=$TAG | ||
fi |
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
</template> | ||
|
||
<script> | ||
import '../src/style/index.less' | ||
export default { | ||
name: 'app' | ||
} | ||
|
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 |
---|---|---|
|
@@ -59,7 +59,7 @@ | |
} | ||
] | ||
}, { | ||
"groupName": "Data", | ||
"groupName": "Data Display", | ||
"list": [ | ||
{ | ||
"path": "/tag", | ||
|
Oops, something went wrong.