This file contains hidden or 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
| class MyPlugin { | |
| apply(compiler) { | |
| compiler.hooks.compilation.tap('MyPlugin', (compilation) => { | |
| compilation.hooks.afterOptimizeDependencies.tap('MyPlugin', ( ) => { | |
| const dependencyGraph = compilation.moduleGraph; | |
| // 获取所有模块 | |
| const modules = compilation.modules; | |
| // 构建模块映射表 |
This file contains hidden or 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
| const globby = require('globby'); | |
| const path = require('path'); | |
| const { detectiveModuleAndRequire } = require('detective-module'); | |
| const fse = require('fs-extra'); | |
| const isBuiltinModule = require('is-builtin-module'); | |
| const log = require('npmlog'); | |
| require('colors'); | |
| function unique(arr) { | |
| return Array.from(new Set(arr)); |
This file contains hidden or 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
| let makeAllPackagesExternalPlugin = { | |
| name: 'make-all-packages-external', | |
| setup(build) { | |
| let filter = /^[^.\/]|^\.[^.\/]|^\.\.[^\/]/ // Must not start with "/" or "./" or "../" | |
| build.onResolve({ filter }, args => ({ path: args.path, external: true })) | |
| }, | |
| } |
This file contains hidden or 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
| # 取消 dock 延时 | |
| defaults write com.apple.Dock autohide-delay -float 0 && killall Dock | |
| defaults delete com.apple.Dock autohide-delay && killall Dock | |
| # each run | |
| for d in ./*/ ; do (cd "$d" && somecommand); done | |
| # git remove merged branchs | |
| alias gbdd="git branch --merged | grep -v '^* master$' | grep -v '^ master$' | xargs git branch -d" |
This file contains hidden or 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
| const FETCH_TIMEOUT = 5000; | |
| let didTimeOut = false; | |
| new Promise(function(resolve, reject) { | |
| const timeout = setTimeout(function() { | |
| didTimeOut = true; | |
| reject(new Error('Request timed out')); | |
| }, FETCH_TIMEOUT); | |
| fetch('https://davidwalsh.name/?xx1') |
This file contains hidden or 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
| // 打开默认编辑器 | |
| const openEditor = (cwd, editor, basePath) => { | |
| let editorPath = basePath; | |
| if (editor === 'Sublime') { | |
| if (isMac) { | |
| editorPath = join(basePath, '/Contents/SharedSupport/bin/subl'); | |
| } | |
| if (isWin) { |
This file contains hidden or 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
| #!/bin/sh | |
| git filter-branch --env-filter ' | |
| OLD_EMAIL=$OLD_EMAIL | |
| CORRECT_NAME=$GIT_NAME | |
| CORRECT_EMAIL=$GIT_EMAIL | |
| if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ] | |
| then | |
| export GIT_COMMITTER_NAME="$CORRECT_NAME" |
This file contains hidden or 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
| var fs = require('fs'); | |
| var zlib = require('zlib'); | |
| var path = require('path'); | |
| var tar = require('tar'); | |
| var mkdirp = require('mkdirp'); | |
| // 全解压 | |
| fs.createReadStream(path.resolve('./ice-2.0.50.tgz')) | |
| .on('error', console.log) | |
| .pipe(zlib.Unzip()) |
This file contains hidden or 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
| git diff --shortstat 2> /dev/null | tail -n1 |
This file contains hidden or 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
| alias server='open http://localhost:8000 && python -m SimpleHTTPServer' |
NewerOlder