Skip to content

Commit

Permalink
Added rollup to build
Browse files Browse the repository at this point in the history
  • Loading branch information
wenzhixin committed May 7, 2019
1 parent f0e0798 commit cb4a659
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 1 deletion.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ deploy_key.enc
deploy.sh
Gemfile
Gemfile.lock
src
16 changes: 15 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,25 @@
"version": "1.1.2",
"description": "Show/hide password plugin for twitter bootstrap.",
"main": "dist/bootstrap-show-password.min.js",
"module": "dist/bootstrap-show-password-es.min.js",
"devDependencies": {
"eslint": "^5.16.0"
"@babel/preset-env": "^7.4.4",
"eslint": "^5.16.0",
"headr": "^0.0.4",
"npm-run-all": "^4.1.5",
"rollup": "^1.11.3",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-babel-minify": "^8.0.0",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-inject": "^2.2.0",
"rollup-plugin-node-resolve": "^4.2.3"
},
"scripts": {
"lint": "eslint src",
"build:base": "rollup -c",
"build:min": "NODE_ENV=production rollup -c",
"build:banner": "find dist -name '*.min.js' -exec headr {} -o {} --version --homepage --author --license \\;",
"build": "run-s build:*",
"docs": "bundle exec jekyll build",
"docs-serve": "bundle exec jekyll serve"
},
Expand Down
60 changes: 60 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import babel from 'rollup-plugin-babel'
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import minify from 'rollup-plugin-babel-minify'
import inject from 'rollup-plugin-inject'

const external = ['jquery']
const globals = {
jquery: 'jQuery'
}
const config = []
const plugins = [
inject({
include: '**/*.js',
exclude: 'node_modules/**',
$: 'jquery'
}),
resolve(),
commonjs(),
babel({
exclude: 'node_modules/**'
})
]

if (process.env.NODE_ENV === 'production') {
plugins.push(minify({
comments: false
}))
}

let out = 'dist/bootstrap-show-password.js'
if (process.env.NODE_ENV === 'production') {
out = out.replace(/.js$/, '.min.js')
}
config.push({
input: 'src/bootstrap-show-password.js',
output: {
name: 'BootstrapShowPassword',
file: out,
format: 'umd',
globals
},
external,
plugins
})

out = 'dist/bootstrap-show-password.esm.js'
if (process.env.NODE_ENV === 'production') {
out = out.replace(/.js$/, '.min.js')
}
config.push({
input: 'src/bootstrap-show-password.js',
output: {
file: out,
format: 'esm'
},
plugins: plugins.slice(1)
})

export default config
12 changes: 12 additions & 0 deletions src/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@babel/env",
{
"modules": false,
"useBuiltIns": "usage",
"corejs": 3
}
]
]
}

0 comments on commit cb4a659

Please sign in to comment.