基于vue2.0的后管系统(配置篇)
一些项目依赖package.json
{
"name": "frontend",
"description": "tssp based on vue2.0 frame",
"version": "1.0.0",
"author": "tom.h@vipshop.com",
"private": true,
"scripts": {
"dev": "et -c element-variables.scss -o element-ui && cross-env NODE_ENV=development webpack --progress --hide-modules --config config/webpack.tssp.config.js",
"start": "cross-env NODE_ENV=development webpack-dev-server --inline --hot --config config/webpack.tssp.config.js",
"uattest": "et -c element-variables.scss -o element-ui && node config/removefile.js && cross-env NODE_ENV=uat webpack --progress --hide-modules --config config/webpack.tssp.config.js",
"pretest": "et -c element-variables.scss -o element-ui && node config/removefile.js && cross-env NODE_ENV=pre webpack --progress --hide-modules --config config/webpack.tssp.config.js",
"sittest": "et -c element-variables.scss -o element-ui && node config/removefile.js && cross-env NODE_ENV=sit webpack --progress --hide-modules --config config/webpack.tssp.config.js",
"build": "et -c element-variables.scss -o element-ui && node config/removefile.js && cross-env NODE_ENV=production webpack --progress --hide-modules --config config/webpack.tssp.config.js"
},
"dependencies": {
"axios": "^0.17.1",
"babel-polyfill": "6.23.0",
"echarts": "^4.1.0",
"font-awesome": "^4.7.0",
"qs": "^6.5.1",
"vue": "2.5.0",
"vue-progressbar": "^0.7.2",
"vue-router": "2.3.1",
"vuebar": "0.0.4",
"vuex": "2.2.1"
},
"babel": {
"presets": [
"es2015",
"stage-3"
],
"ignore": [
"./static/particles.js",
"./static/jsencrypt.min.js"
]
},
"devDependencies": {
"babel-core": "^6.24.0",
"babel-loader": "^6.4.1",
"babel-preset-es2015": "^6.24.0",
"babel-preset-stage-3": "^6.22.0",
"copy-webpack-plugin": "^4.0.1",
"cross-env": "^3.2.4",
"css-loader": "^0.27.3",
"element-theme": "^2.0.1",
"element-theme-chalk": "git+https://github.com/ElementUI/theme-chalk.git",
"element-theme-default": "1.3.6",
"element-ui": "^2.4",
"express": "^4.16.2",
"express-proxy-mock": "^1.2.13",
"extract-text-webpack-plugin": "^2.1.0",
"file-loader": "^0.10.1",
"gulp": "^3.9.1",
"gulp-git": "^2.2.0",
"gulp-util": "^3.0.8",
"html-webpack-plugin": "^2.28.0",
"js-cookie": "^2.2.0",
"node-sass": "^4.5.0",
"postcss-css-variables": "0.7.0",
"postcss-cssnext": "2.10.0",
"postcss-import": "9.1.0",
"postcss-loader": "1.3.3",
"rimraf": "2.6.2",
"sass-loader": "^5.0.1",
"sass-resources-loader": "^1.3.1",
"vue-lazy-render": "^1.0.20",
"vue-loader": "11.3.4",
"vue-style-loader": "2.0.5",
"vue-template-compiler": "2.5.0",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.4.2",
"webpack-merge": "^2.6.1"
}
}
一些打包脚本
"scripts": {
"dev": "et -c element-variables.scss -o element-ui && cross-env NODE_ENV=development webpack --progress --hide-modules --config config/webpack.tssp.config.js",
"start": "cross-env NODE_ENV=development webpack-dev-server --inline --hot --config config/webpack.tssp.config.js",
"uattest": "et -c element-variables.scss -o element-ui && node config/removefile.js && cross-env NODE_ENV=uat webpack --progress --hide-modules --config config/webpack.tssp.config.js",
"pretest": "et -c element-variables.scss -o element-ui && node config/removefile.js && cross-env NODE_ENV=pre webpack --progress --hide-modules --config config/webpack.tssp.config.js",
"sittest": "et -c element-variables.scss -o element-ui && node config/removefile.js && cross-env NODE_ENV=sit webpack --progress --hide-modules --config config/webpack.tssp.config.js",
"build": "et -c element-variables.scss -o element-ui && node config/removefile.js && cross-env NODE_ENV=production webpack --progress --hide-modules --config config/webpack.tssp.config.js"
},
script解读:
et -c element-variables.scss -o element-ui 打包本地配置好的elementUI样式
cross-env NODE_ENV=development 将环境变量改成不同的值,对应不同模式的打包
webpack --progress --hide-modules --config config/webpack.tssp.config.js 根据config文件夹中的webpack.tssp.config.js配置打包文件,显示进度
webpack-dev-server --inline --hot --config config/webpack.tssp.config.js 启动webpack服务,开启热更新
babel解读:
"babel": {
"presets": [
"es2015",
"stage-3"
],
"ignore": [
"./static/particles.js",
"./static/jsencrypt.min.js"
]
},
"presets": [ "es2015", "stage-3"] 将代码打包成es2015和stage-3 "ignore": ["./static/particles.js","./static/jsencrypt.min.js"] 忽略转义某些文件,一些库的脚本转义后会报错,故用之
webpack配置
webpack.tssp.config.js
const path = require('path');
const webpack = require('webpack');
const cssnext = require('postcss-cssnext');
const atImport = require('postcss-import');
const cssvariables = require('postcss-css-variables');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin'); const devSrc = 'http://localhost:8099/static/';
const devOutputPath = '../dist/static';
const prodSrc = './static/';
const prodOutputPath = '../dist/static'; const Util = require('./util') const PATH_DIST = {
font: 'font/',
img: 'image/',
css: 'css/',
js: 'js/',
root:'../'
};
const isProduction = process.env.NODE_ENV !== 'development'; //环境,dev、production
const BASE_API_MAP = {
"development": '""',
"uat": '"http://11.114.0.12:8050/nfsm-uat/"',
"sit": '"http://11.114.0.12:8050/nfsm-sit/"',
"pre": '"http://11.111.1.5:8050/nfsm-pre/"',
"production": '"http://22.231.1.5:10080/nfsm/"'
}
const UPLOADFILE_MAP = {
"development": '"http://11.114.0.12:8050/nfsm-sit/"',
"uat": '"http://11.114.0.12:8050/nfs-uat"',
"sit": '"http://11.114.0.12:8050/nfs-sit"',
"pre": '"http://11.111.1.5:8050/nfs-pre"',
"production": '"http://22.231.1.5:10080/nfs"'
}
const proxyHost = 'http://11.114.0.12:8050/nfsm-sit/'; const host = isProduction ? prodSrc : devSrc;
const outputPath = isProduction ? prodOutputPath : devOutputPath;
const extractElementUI = new ExtractTextPlugin(PATH_DIST.css + 'element.css' + (isProduction ? '?[contenthash:8]' : ''));
const extractCSS = new ExtractTextPlugin(PATH_DIST.css + 'app.css' + (isProduction ? '?[contenthash:8]' : '')); module.exports = function (env) {
let Config = {
entry: {
element: ['element-ui'],
vue: ['vue', 'axios', 'vue-router', 'vuex'],
app: './src/main.js'
},
output: {
path: path.resolve(__dirname, outputPath),
publicPath: host,
filename: PATH_DIST.js + '[name].js' + (isProduction ? '?[chunkhash:8]' : '')
},
module: {
rules: [{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
scss: Util.generateSassResourceLoader(),
sass: Util.generateSassResourceLoader(),
css: extractCSS.extract({
use: 'css-loader!postcss-loader',
fallback: 'vue-style-loader'
})
}
}
},
{
test: function (path) {
if (/\.css$/.test(path) && (/element-ui/).test(path)) {
console.log(path)
return true;
} else {
return false;
}
},
loader: extractElementUI.extract({
use: 'css-loader!postcss-loader'
})
},
{
test: function (path) {
if (/\.css$/.test(path) && !(/element-ui/).test(path)) {
return true;
} else {
return false;
}
},
loader: extractCSS.extract({
use: 'css-loader!postcss-loader'
})
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(woff|svg|eot|ttf)\??.*$/, //字体文件
loader: 'file-loader',
options: {
publicPath: '../font/',
outputPath: PATH_DIST.font,
name: '[name].[ext]'
}
},
{
test: /\.(gif|jpg|png|ico)\??.*$/, //图片
loader: 'file-loader',
options: {
name: PATH_DIST.img + '[name].[ext]'
}
},
{
test: /\.scss$/,
use: Util.generateSassResourceLoader()
},
{
test: /\.sass/,
use: Util.generateSassResourceLoader()
}, ]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: ['element', 'vue']
}),
extractElementUI,
extractCSS,
// copy custom static assets
new CopyWebpackPlugin([{
from: path.resolve(__dirname, '../static'),
to: '',
ignore: ['.*']
}]),
new webpack.LoaderOptionsPlugin({
options: {
postcss: function () {
return [atImport({
path: [path.resolve(__dirname, '../src')]
}), cssnext, cssvariables];
}
},
minimize: isProduction
}),
new HtmlWebpackPlugin({
title: '消息推送平台',
template: 'index.html',
filename: '../index.html',
inject: false,
path: host,
chunks: ['element', 'vue', 'app']
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': isProduction ? '"production"' : '"development"',
'process.env.BASE_API': BASE_API_MAP[process.env.NODE_ENV],
'process.env.UPLOADFILE': UPLOADFILE_MAP[process.env.NODE_ENV]
}),
],
performance: {
hints: isProduction ? 'warning' : false
},
devtool: isProduction ? false : '#eval-source-map',
resolve: {
alias: {
'src': path.resolve(__dirname, '../src'),
'@': path.resolve(__dirname, '../src'),
'lib': path.resolve(__dirname, '../static'),
'scss': path.resolve(__dirname, '../src/scss/')
},
extensions:[".js"]
}
}; if (isProduction) {
Config.plugins = Config.plugins.concat([
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
})
]);
} else {
let context = ['/auth', '/myAccount', '/user', '/role', '/resource', '/task', '/enum', '/draft', '/customerLabel','/accessChannel']
Config.devServer = {
historyApiFallback: true,
publicPath: '/static/',
disableHostCheck: true,
noInfo: true,
hot: true,
host: 'localhost',
proxy: [{
context: context,
//target: 'http://11.112.0.100:9750',
target: proxyHost,
changeOrigin: true,
secure: false
}/* , {
context: '/file',
target: 'http://11.112.0.100:9742',
changeOrigin: true,
secure: false
} */],
port: 8099,
watchOptions: {
poll: false,
ignored: ['node_modules/**', 'config/**', 'common/**', 'dist/**']
},
headers: {
'Access-Control-Allow-Origin': '*'
}
};
}
return Config;
};
基于vue2.0的后管系统(配置篇)的更多相关文章
- 基于vue2.0前端组件库element中 el-form表单 自定义验证填坑
eleme写的基于vue2.0的前端组件库: http://element.eleme.io 我在平时使用过程中,遇到的问题. 自定义表单验证出坑: 1: validate/resetFields 未 ...
- 基于vue2.0的一个豆瓣电影App
1.搭建项目框架 使用vue-cli 没安装的需要先安装 npm intall -g vue-cli 使用vue-cli生成项目框架 vue init webpack-simple vue-movie ...
- 基于vue2.0的在线电影APP,
基于vue2.0构建的在线电影网[film],webpack + vue + vuex + vue-loader + keepAlive + muse-ui + cordova 全家桶,cordova ...
- 基于vue2.0的分页组件开发
今天安排的任务是写基于vue2.0的分页组件,好吧,我一开始是觉得超级简单的,但是越写越写不出来,写的最后乱七八糟的都不知道下句该写什么了,所以重新捋了思路,小结一下- 首先写组件需要考虑: 要从父组 ...
- vue-swiper 基于Vue2.0开发 轻量、高性能轮播插件
vue-swiper 基于 Vue2.0 开发,基本满足大部分功能 轻量.高性能轮播插件.目前支持 无缝衔接自动轮播.无限轮播.手势轮播 没有引入第三方库,原生 js 封装,打包之后只有 8.2KB ...
- 基于vue2.0打造移动商城页面实践 vue实现商城购物车功能 基于Vue、Vuex、Vue-router实现的购物商城(原生切换动画)效果
基于vue2.0打造移动商城页面实践 地址:https://www.jianshu.com/p/2129bc4d40e9 vue实现商城购物车功能 地址:http://www.jb51.net/art ...
- vue2.0 开发实践总结之入门篇
vue2.0 据说也出了很久了,博主终于操了一次实刀. 整体项目采用 vue + vue-router + vuex (传说中的vue 全家桶 ),构建工具使用尤大大推出的vue-cli 后续文 ...
- 饿了么基于Vue2.0的通用组件开发之路(分享会记录)
Element:一套通用组件库的开发之路 Element 是由饿了么UED设计.饿了么大前端开发的一套基于 Vue 2.0 的桌面端组件库.今天我们要分享的就是开发 Element 的一些心得. 官网 ...
- 基于vue2.0 +vuex+ element-ui后台管理系统:包括本地开发调试详细步骤
效果演示地址, github地址: demo演示: 1.About 此项目是 vue2.0 + element-ui + node+mongodb 构建的后台管理系统,所有的数据都是从 ...
随机推荐
- UESTC--1727
原题链接:http://acm.uestc.edu.cn/problem.php?pid=1727 分析:用 l[i] 记录第 i 层楼有多少物品需要往上继续搬运,如果某层楼没有物品,但是更上面还有, ...
- 高并发大容量NoSQL解决方案探索
大数据时代,企业对于DBA也提出更高的需求.同时,NoSQL作为近几年新崛起的一门技术,也受到越来越多的关注.本文将基于个推SRA孟显耀先生所负责的DBA工作,和大数据运维相关经验,分享两大方向内容: ...
- Uniform Distribution均匀分布
sklearn实战-乳腺癌细胞数据挖掘(博主亲自录制视频教程) https://study.163.com/course/introduction.htm?courseId=1005269003&am ...
- JAVA多线程提高三:线程范围内共享变量&ThreadLocal
今天我们学习的是如何在线程自己的范围内达到变量数据的共享,而各个线程之间又是互相独立开来,各自维护的,即我们说的ThreadLocal的作用. 一.概念 可以将每个线程用到的数据与对应的线程号存放到一 ...
- 【CodeForces】713 C. Sonya and Problem Wihtout a Legend
[题目]C. Sonya and Problem Wihtout a Legend [题意]给定n个数字,每次操作可以对一个数字±1,求最少操作次数使数列递增.n<=10^5. [算法]动态规划 ...
- array_unshift() 函数
出处:http://www.w3school.com.cn/php/func_array_unshift.asp
- 使用Skyworking 作全链路api调用监控,Integration of Skyworking, auditing the whole chain circuit.
Applicable scenario: Structure Map ~ Skywalking uses elasticsearch to store data, don't mistake elas ...
- javaScript 中的一些日常用法总结
从今天开始把开发中常用到的js语法 一一记录下来 方便以后复习回顾用: 1:对字符串进行替换 replace 以及 replaceAll replace : var begin_date =begin ...
- JAVA 企业培训
- Django之kindeditor
1.什么是kindeditor? KindEditor是一套开源的HTML可视化编辑器,主要用于让用户在网站上获得所见即所得编辑效果,兼容IE.Firefox.Chrome.Safari.Opera等 ...