Skip to content

Commit

Permalink
perf(config): refactor to get ride of cloneDeep
Browse files Browse the repository at this point in the history
  • Loading branch information
crimx committed May 15, 2018
1 parent cada372 commit d986b53
Show file tree
Hide file tree
Showing 4 changed files with 436 additions and 223 deletions.
2 changes: 1 addition & 1 deletion config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const extractTextPluginOptions = shouldUseRelativeAssetPaths
const entries = fs.readdirSync(paths.appSrc)
.filter(name => !name.startsWith('_'))
.map(name => ({name, dirPath: path.join(paths.appSrc, name)}))
.filter(({name, dirPath}) => !/^assets|components|manifest|typings$/.test(name) && fs.lstatSync(dirPath).isDirectory())
.filter(({name, dirPath}) => !/^assets|components|manifest|typings|app-config$/.test(name) && fs.lstatSync(dirPath).isDirectory())

// This is the production configuration.
// It compiles slowly and is focused on producing a fast and minimal bundle.
Expand Down
27 changes: 27 additions & 0 deletions src/app-config/context-menus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export function getAllContextMenus () {
const allContextMenus = {
google_page_translate: 'x',
youdao_page_translate: 'x',
google_search: 'https://www.google.com/#newwindow=1&q=%s',
baidu_search: 'https://www.baidu.com/s?ie=utf-8&wd=%s',
bing_search: 'https://www.bing.com/search?q=%s',
google_translate: 'https://translate.google.cn/#auto/zh-CN/%s',
etymonline: 'http://www.etymonline.com/index.php?search=%s',
merriam_webster: 'http://www.merriam-webster.com/dictionary/%s',
oxford: 'http://www.oxforddictionaries.com/us/definition/english/%s',
cambridge: 'http://dictionary.cambridge.org/spellcheck/english-chinese-simplified/?q=%s',
youdao: 'http://dict.youdao.com/w/%s',
dictcn: 'https://dict.eudic.net/dicts/en/%s',
iciba: 'http://www.iciba.com/%s',
liangan: 'https://www.moedict.tw/~%s',
guoyu: 'https://www.moedict.tw/%s',
longman_business: 'http://www.ldoceonline.com/search/?q=%s',
bing_dict: 'https://cn.bing.com/dict/?q=%s'
}

// Just for type check. Keys in allContextMenus are useful so no actual assertion
// tslint:disable-next-line:no-unused-expression
allContextMenus as { [id: string]: string }

return allContextMenus
}
Loading

0 comments on commit d986b53

Please sign in to comment.