🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

jtaro-bundle

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jtaro-bundle

A bundle plugin for JTaro

latest
Source
npmnpm
Version
0.3.1
Version published
Maintainers
1
Created
Source

JTaro-Bundle

为JTaro服务的打包脚本

安装

npm install -D jtaro-bundle

方法

bundle

  • 根据index.html的href和src属性提取需要的文件
  • 将整个文件夹所有第一层js文件(Vue页面组件)合并到一个文件并创建Vue组件
  • 直接拷贝指定文件(夹)

选项:

必填备注
origin<String>Y开发目录的index.html
target<String>Y生产目录的index.html模板
copies<Array>N直接拷贝的文件(夹)
rollupPlugins<Array>N参考 Rollup JavaScript-API#plugins
sourceMap<Boolean>N默认为false,是否开启sourceMap
callback<Function>N打包完成后执行的回调

示例:

// nodejs
var jtaroBundle = require('jtaro-bundle')
var uglify = require('rollup-plugin-uglify')
var babel = require('rollup-plugin-babel')

jtaroBundle.bundle({
  origin: 'dev/index.html',  // 开发目录的index.html
  target: 'pro/index_template.html',  // 生产目录的index.html模板
  // 直接拷贝的文件(夹),注意:文件夹后不要带/,否则windows10拷贝的文件会有问题,例:./assets不要写成./assets/
  copies: ['./data.json', './assets'],
  // 自定义使用rollup打包时使用的插件
  // uglify不能压缩ES6语法,所以babel要放在uglify前面
  rollupPlugins: [babel({
    include: './dev/pages/*.js', // 相对于该脚本文件(请注意区分与jtaro-module的babel插件路径)
    presets: [
      [
        'es2015',
        {
          'modules': false
        }
      ]
    ]
  },
    uglify()],
  sourceMap: true,
  callback: function () {
    console.log('打包完成')
  }
})

index

用于将文件夹里所有js文件索引到一个js文件里,给rollup.js提供入口

require('jtaro-bundle').index(path[, name])

  • path 必须,要提取索引的目录
  • name 可选,索引文件的名称,如果不填,默认为<目录名> + _index.js
var jtaroBundle = require('jtaro-bundle')
jtaroBundle.index('dev/pages')
// jtaroBundle.index('dev/pages', 'myIndex.js') // 自定义文件名

将会生成dev/pages.js文件,dev/pages.js文件内容类似如下形式,引入js并创建Vue组件

import p2 from './pages/detail.js'
Vue.component('pages__detail', p2)
import p4 from './pages/home.js'
Vue.component('pages__home', p4)
import p8 from './pages/reply.js'
Vue.component('pages__reply', p8)

LOG

v0.3.1 (2018-06-07)

  • 使用 md5 hash 替换文件后面的时间戳,保证文件不变,不更新缓存
  • 使用 copySync 替换 copy ,解决 windows 系统拷贝文件失败的问题

v0.3.0 (2017-07-10)

  • 添加回调函数,打包完成后可执行回调
  • 添加创建带时间戳路径的index.html文件用于清除缓存,因此原index.html模板文件要修改为index_template.html

v0.2.6 (2017-06-09)

  • 修复工程目录路径带.报错的问题

v0.2.5 (2017-05-19)

  • 更新依赖rollup-plugin-jtaro-module@0.2.0

v0.2.4 (2017-05-16)

  • 更新依赖rollup-plugin-jtaro-module@0.1.0

v0.2.3 (2017-05-04)

  • 更新依赖rollup-plugin-jtaro-module@0.0.7

v0.2.2 (2017-05-02)

  • 补充修复windows下index方法解释\反斜杠路径错误的问题

v0.2.1 (2017-05-01)

  • 修复windows下index方法解释\反斜杠路径错误的问题

v0.2.0 (2017-03-21)

  • 新增index方法,用于将文件夹里所有js文件索引到一个js文件里,给rollup.js提供入口

v0.1.2 (2017-03-13)

  • 添加sourceMap选项

v0.1.1 (2017-02-28)

  • 添加rollupPlugins选项

Keywords

JTaro-Bundle

FAQs

Package last updated on 07 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts