-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9d20490
Showing
12 changed files
with
1,823 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"presets": [ | ||
["latest", { | ||
"es2015": { | ||
"modules": false | ||
} | ||
}] | ||
], | ||
"plugins": [ | ||
"external-helpers" | ||
] | ||
} |
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,2 @@ | ||
build/*.js | ||
dist/*.js |
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,22 @@ | ||
module.exports = { | ||
root: true, | ||
parser: 'babel-eslint', | ||
parserOptions: { | ||
sourceType: 'module' | ||
}, | ||
env: { | ||
browser: true, | ||
}, | ||
extends: 'airbnb-base', | ||
rules: { | ||
indent: [2, 'tab'], | ||
'no-tabs': 0, | ||
'import/extensions': 0, | ||
'no-console': 0, | ||
semi: [2, 'always'], | ||
'no-unused-vars': 0, | ||
'no-unneeded-ternary': ['error', { | ||
defaultAssignment: false | ||
}] | ||
} | ||
}; |
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,18 @@ | ||
# OSX | ||
.DS_Store | ||
|
||
# Android/IJ | ||
.idea | ||
.gradle | ||
local.properties | ||
.project | ||
|
||
# Vim | ||
*.swp | ||
|
||
# node.js | ||
node_modules/ | ||
npm-debug.log | ||
|
||
# custom | ||
dist/*.map |
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,5 @@ | ||
DomInspector | ||
-------------------------------- | ||
|
||
Dom inspect like chrome dev tools. | ||
|
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,57 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
var rollup = require('rollup'); | ||
var uglify = require('uglify-js'); | ||
|
||
var env = require('./env.js'); | ||
|
||
var version = require('../package.json').version; | ||
|
||
var config = require('./config.js'); | ||
|
||
var banner = '/*\n' + | ||
' * DomInspector v' + version + '\n' + | ||
' * (c) ' + new Date().getFullYear() + ' luoye <[email protected]>\n' + | ||
' */'; | ||
|
||
function getSize(code) { | ||
return (code.length / 1024).toFixed(2) + 'kb'; | ||
}; | ||
|
||
function blue(str) { | ||
return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m'; | ||
}; | ||
|
||
function write(dest, code) { | ||
return new Promise(function(resolve, reject) { | ||
fs.writeFile(dest, code, function(err) { | ||
if (err) return reject(err); | ||
console.log(blue(dest) + ' ' + getSize(code)); | ||
resolve(code); | ||
}); | ||
}); | ||
}; | ||
|
||
rollup.rollup(config).then(function(bundle) { | ||
return bundle.generate({ | ||
banner: banner, | ||
format: 'umd', | ||
moduleName: 'DomInspector' | ||
}).code; | ||
}).then(function(code) { | ||
return write(path.join(__dirname, '../dist/dom-inspector.js'), code); | ||
}).then(function(code) { | ||
return uglify.minify(code, { | ||
fromString: true, | ||
output: { | ||
preamble: banner, | ||
ascii_only: true | ||
}, | ||
compress: { | ||
drop_console: true | ||
} | ||
}).code; | ||
}).then(function(code) { | ||
return write(path.join(__dirname, '../dist/dom-inspector.min.js'), code); | ||
}); |
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,24 @@ | ||
var path = require('path'); | ||
|
||
var complieTools = require('rollup-plugin-babel'); | ||
var eslint = require('rollup-plugin-eslint'); | ||
|
||
var env = require('./env.js'); | ||
|
||
var config = { | ||
entry: path.join(__dirname, '../src/index.js'), | ||
plugins: [ | ||
eslint(), | ||
complieTools() | ||
] | ||
}; | ||
|
||
if (env === 'dev') { | ||
module.exports = Object.assign({ | ||
format: 'umd', | ||
moduleName: 'DomInspector', | ||
dest: path.join(__dirname, '../dist/dom-inspector.js') | ||
}, config); | ||
} else { | ||
module.exports = config; | ||
} |
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,5 @@ | ||
var minimist = require('minimist'); | ||
|
||
var argv = minimist(process.argv.slice(2)); | ||
|
||
module.exports = argv.env || 'production'; |
Empty file.
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,27 @@ | ||
{ | ||
"name": "dom-inspector", | ||
"version": "1.0.0", | ||
"description": "dom inspect like chrom dev tools.", | ||
"author": "luoye <[email protected]>", | ||
"main": "dist/dom-inspector.min.js", | ||
"scripts": { | ||
"dev": "./node_modules/.bin/rollup -w -m -c build/config.js --env=dev", | ||
"build": "node build/build.js" | ||
}, | ||
"devDependencies": { | ||
"babel-core": "^6.22.1", | ||
"babel-plugin-external-helpers": "^6.22.0", | ||
"babel-preset-latest": "^6.16.0", | ||
"rollup-plugin-babel": "^2.6.1", | ||
"babel-eslint": "^7.2.2", | ||
"eslint": "^3.14.1", | ||
"eslint-friendly-formatter": "^2.0.7", | ||
"eslint-config-airbnb-base": "^11.0.1", | ||
"eslint-plugin-import": "^2.2.0", | ||
"minimist": "^1.2.0", | ||
"rollup": "^0.36.3", | ||
"rollup-plugin-eslint": "^3.0.0", | ||
"rollup-watch": "^2.5.0", | ||
"uglify-js": "^2.7.3" | ||
} | ||
} |
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 @@ | ||
console.log('hello world!'); |
Oops, something went wrong.