vue3-yuanma/scripts/dev.js

45 lines
1.0 KiB
JavaScript
Raw Normal View History

2018-09-20 00:21:00 +08:00
/*
Run Rollup in watch mode for development.
To specific the package to watch, simply pass its name and the desired build
2018-09-20 00:46:55 +08:00
formats to watch (defaults to "global"):
2018-09-20 00:21:00 +08:00
```
# name supports fuzzy match. will watch all packages with name containing "dom"
2021-10-09 02:23:30 +08:00
nr dev dom
2018-09-20 00:21:00 +08:00
# specify the format to output
2021-10-09 02:23:30 +08:00
nr dev core --formats cjs
# Can also drop all __DEV__ blocks with:
2021-10-09 02:23:30 +08:00
__DEV__=false nr dev
2018-09-20 00:21:00 +08:00
```
*/
2018-09-19 23:35:38 +08:00
const execa = require('execa')
const { fuzzyMatchTarget } = require('./utils')
2018-09-20 00:21:00 +08:00
const args = require('minimist')(process.argv.slice(2))
2019-10-02 23:39:00 +08:00
const target = args._.length ? fuzzyMatchTarget(args._)[0] : 'vue'
2018-09-20 00:21:00 +08:00
const formats = args.formats || args.f
const sourceMap = args.sourcemap || args.s
const commit = execa.sync('git', ['rev-parse', 'HEAD']).stdout.slice(0, 7)
2018-09-19 23:35:38 +08:00
execa(
'rollup',
[
'-wc',
'--environment',
[
`COMMIT:${commit}`,
`TARGET:${target}`,
`FORMATS:${formats || 'global'}`,
sourceMap ? `SOURCE_MAP:true` : ``
]
.filter(Boolean)
.join(',')
],
2018-09-19 23:35:38 +08:00
{
stdio: 'inherit'
}
)