Commit 4093645f authored by likely's avatar likely

init

parents
{
"presets": [
[
"env",
{
"modules": false
}
]
],
"plugins": [
"external-helpers"
]
}
\ No newline at end of file
dist
node_modules
\ No newline at end of file
const gulp = require('gulp')
const gulpClean = require('gulp-clean')
const runSequence = require('run-sequence')
const rollup = require('rollup')
const rollupCommonjs = require('rollup-plugin-commonjs')
const rollupNoderesolve = require('rollup-plugin-node-resolve')
const rollupBabel = require('rollup-plugin-babel')
const pluginDir = './src/' // 插件库目录
const outputPath = './dist/'
let pluginName
let pluginPath
const rollupBundle = name => {
return async cb => {
const bundle = await rollup.rollup({
input: `${pluginPath}/${name}.js`,
plugins: [
rollupNoderesolve({
jsnext: true,
main: true
}),
rollupBabel({
exclude: ['node_modules/**']
}),
rollupCommonjs({
include: ['node_modules/**']
})
]
})
await bundle.write({
file: `${outputPath}${name}.js`,
format: 'umd',
sourcemap: true
})
}
}
// clean bundle
gulp.task('bundle:clean', cb => {
return gulp.src(outputPath)
.pipe(gulpClean())
})
// bundle vendor
gulp.task('bundle:vendor', rollupBundle('vendor'))
// bundle plugin
gulp.task('bundle:plugin', rollupBundle('plugin'))
// bundle init
gulp.task('bundle:init', ['bundle:clean'], cb => {
pluginName = 'pluginA'
pluginPath = pluginDir + pluginName
cb()
})
// preview plugin
gulp.task('preview', ['bundle:init'], cb => {
runSequence(['bundle:vendor', 'bundle:plugin'], cb)
})
// build plugin
gulp.task('build', [], cb => {
})
\ No newline at end of file
{
"name": "jimu-plugin",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"babel-core": "^6.26.3",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"gulp": "^3.9.1",
"gulp-clean": "^0.4.0",
"rollup": "^0.65.2",
"rollup-plugin-babel": "3",
"rollup-plugin-commonjs": "^9.1.6",
"rollup-plugin-node-resolve": "^3.4.0",
"run-sequence": "^2.2.1"
},
"devDependencies": {
"jquery": "^3.3.1"
}
}
$('.app').html('这是一个测试插件')
\ No newline at end of file
<html>
<head>
<title>插件预览页</title>
</head>
<body>
<div class="app"></div>
<script href="/vendor.js"></script>
<script href="/plugin.js"></script>
</body>
</html>
\ No newline at end of file
import $ from 'jquery'
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment