1、vue项目的构建过程
安装vue
root:vueWork root$ npm install vue
+ vue@2.5.9
added 1 package in 10.749s
root:vueWork root$ vue -V
2.9.1
vue依赖于node.js,需要确保计算机已经安装了node.js.
root:vueWork root$ node -v
v6.11.4
全局安装vue-cli
npm install –global vue-cli
创建一个基于webpack模板的新基目
vue init webpack myProject
安装依赖
cd myProject
npm install
npm run dev
安装成功提示
root:vueWork root$ npm install --global vue-cli
npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
/usr/local/bin/vue-init -> /usr/local/lib/node_modules/vue-cli/bin/vue-init
/usr/local/bin/vue -> /usr/local/lib/node_modules/vue-cli/bin/vue
/usr/local/bin/vue-list -> /usr/local/lib/node_modules/vue-cli/bin/vue-list
+ vue-cli@2.9.2
updated 3 packages in 44.243s
root:vueWork root$ vue init webpack myProject
Project name test
Project description A Vue.js project
Author xianglingchuan <xianglingchuan@sina.cn>
Vue build standalone
Install vue-router? Yes
Use ESLint to lint your code? Yes
Pick an ESLint preset Standard
Set up unit tests Yes
Pick a test runner jest
Setup e2e tests with Nightwatch? Yes
vue-cli · Generated "myProject".
To get started:
cd myProject
npm install
npm run dev
Documentation can be found at https://vuejs-templates.github.io/webpack
2、vue项目后台运行命令
命令: nohup npm run dev > /dev/null &
3、修改运行端口号
config/index.js文件中
dev: {
env: require('./dev.env'),
port: 8080,
autoOpenBrowser: true,
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
'/mock': {
target: 'http://localhost:3000',
changeOrigin: true,
pathRewrite: {
'^/mock': ''
}
},
'/api': {
target: 'http://localhost:3000',
changeOrigin: true,
cookieDomainRewrite: {
"*": "*",
},
onProxyReq: function (proxyReq, req, res) {
},
onProxyRes: function (proxyRes, req, res) {
let existingCookies = proxyRes.headers['set-cookie'],
rewrittenCookies = [];
if (existingCookies !== undefined) {
if (!Array.isArray(existingCookies)) {
existingCookies = [existingCookies];
}
for (let i = 0; i < existingCookies.length; i++) {
rewrittenCookies.push(existingCookies[i].replace(/;\s*?(Secure)/i, ''));
}
proxyRes.headers['set-cookie'] = rewrittenCookies;
}
}
}
},
cssSourceMap: false
}
执行命令报: nohup: ignoring input and redirecting stderr to stdout
[root@iZuf6 webapp]# nohup npm run dev > /log/settleWebApp.log
nohup: ignoring input and redirecting stderr to stdout
[1]+ Stopped nohup npm run start > /log/settleWebApp.log
执行命令修改为:
nohup npm run dev > /chroot/wwwlogs/settleWebApp.log &