Open xgqfrms-GitHub opened 6 years ago
npm run dev # 使用mock拦截请求,数据存储在localStroge里
# 打开 http://localhost:8000
https://github.com/pmg1989/dva-admin/issues/22#issuecomment-317683518
C:\Users\xray.anyproxy_certs
rootCA.key
-----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----
https://github.com/pmg1989/dva-admin/issues/22
$ set OPENSSL_CONF=C:/OpenSSL/bin/openssl.cnf
构建:
npm run build-dev local环境发布
npm run build-staging staging 环境发布
npm run build-release release 环境发布
build后的文件将会生成dist目录
conf/webpack.config.js
中的 webpackConfig.plugins 'newband.admin.isMock': true
改为false,以及 src/utils/index.js
中的export request from './request-mock'
改为export request from './request'
conf/webpack.config.js
中的'newband.app.admin.IS_DYNAMIC_LOAD': true
,可以调整JavaScript是否动态按需加载src/utils/mock.js
第二行的mockData
数组中添加src/theme.js
src/utils/config.js
src/utils/request.js
关于为什么使用axios而不是fetch :在一个无服务器的环境中模拟数据请求, Mock不能拦截Fetch,只能拦截XHR,所以我选了一个纯Ajax的库 axios)
"scripts": {
"dev": "dora --plugins \"webpack?config=conf/webpack.config.js&publicPath=/,webpack-hmr,browser-history?index=/src/index.html\"",
"build-dev": "atool-build --config conf/webpack.config.js --publicPath /",
"build-staging": "atool-build --config conf/webpack.config.staging.js --publicPath /",
"build-release": "atool-build --config conf/webpack.config.release.js --publicPath /",
"start": "dora --plugins \"proxy,webpack,webpack-hmr\"",
"lint": "eslint --fix --ext .js,.jsx src/components/layout"
},
"start": "npm run dev --open",
"start": "start http://localhost:8000",
"start": "npm run dev && start http://localhost:8000",
"start": "start npm run dev && start http://localhost:8000",
https://stackoverflow.com/questions/35261535/npm-scripts-start-run-express-and-open-url
"start": "npm run dev && npm run open",
"open": "start http://localhost:8000",
https://stackoverflow.com/questions/30950032/how-can-i-run-multiple-npm-scripts-in-parallel
"dev": "concurrently --kill-others \"npm run start-watch\" \"npm run wp-server\""
"start": "start npm run dev && start http://localhost:8000",
"dev": "npm-run-all --parallel start-watch wp-server"
"start": "\"npm run dev\" && \"start http://localhost:8000\"",
"start": "start http://localhost:8000 && npm run dev",
"start": "start http://localhost:8000 && npm run dev",
https://www.npmjs.com/package/npm-run-all
https://github.com/mysticatea/npm-run-all
$ npm i -D npm-run-all
$ npm-run-all clean lint build:*
$ npm-run-all --parallel watch:*
https://www.npmjs.com/package/concurrently
$ npm i -S concurrently
"start": "concurrently \"command1 arg\" \"command2 arg\"",
Configure The ‘script’ tag In package.json To Run Multiple Commands
# bad
"start": "npm run dev & start http://localhost:8000",
# good
"start": "start http://localhost:8000 & npm run dev",
"start": "npm run dev & npm run open",
"open": "start http://localhost:8000",
Execute multiple npm scripts through VS Code task runner
http://xabikos.com/2015/11/11/Execute-multiple-npm-scripts-through-VS-Code-task-runner/
# npm scripts
"scripts": {
"build-dev": "webpack --bail",
"start-dev": "webpack-dev-server"
},
{
"version": "0.1.0",
"command": "npm",
"isShellCommand": true,
"showOutput": "always",
"args": ["run"],
"isWatching": false,
"tasks": [
{ "taskName": "build-dev" },
{ "taskName": "start-dev" }
]
}
Ctrl + Shift + P
Run Task
Keyboard shortcutsjson
{ "key": "shift+cmd+r", "command": "workbench.action.tasks.runTask" },
{ "key": "shift+cmd+e", "command": "workbench.action.tasks.terminate"}
https://blog.jayway.com/2014/03/28/running-scripts-with-npm/
https://stackoverflow.com/questions/35649551/running-multiple-commands-for-npm-test
"scripts": {
"test": "karma ; protractor ; eslint ; htmlhint ; stylelint"
},
#!/bin/bash
EXIT_STATUS=0
function check_command {
"$@"
local STATUS=$?
if [ $STATUS -ne 0 ]; then
echo "error with $1 ($STATUS)" >&2
EXIT_STATUS=$STATUS
fi
}
check_command karma
check_command protractor
check_command eslint
check_command htmlhint
check_command stylelint
exit $EXIT_STATUS
https://stackoverflow.com/questions/40713752/how-to-open-browser-to-localhost-through-npm-scripts
https://www.npmjs.com/package/openurl
https://github.com/rauschma/openurl
require("openurl").open("https:/www.xgqfrms.xyz")
require("openurl").open("mailto:xgqfrms@xyzdata.com")
require("openurl").mailto(
[
"xgqfrms@xyzdata.com",
"xgqfrms@xyzdata.com"
],
{
subject:"Hello!",
body:"This is\nan automatically sent email!\n"
}
);
https://github.com/pwnall/node-open
open a file or uri with the users preferred application (browser, editor, etc), cross platform
https://www.npmjs.com/package/open
const open = require("open");
open("https://www.google.com");
open("https://www.google.com", "xgqfrms");
npm install open
npm scripts & auto open default browser & run multi commands
macOS
Windows
demo