一些项目依赖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的后管系统(配置篇)的更多相关文章

  1. 基于vue2.0前端组件库element中 el-form表单 自定义验证填坑

    eleme写的基于vue2.0的前端组件库: http://element.eleme.io 我在平时使用过程中,遇到的问题. 自定义表单验证出坑: 1: validate/resetFields 未 ...

  2. 基于vue2.0的一个豆瓣电影App

    1.搭建项目框架 使用vue-cli 没安装的需要先安装 npm intall -g vue-cli 使用vue-cli生成项目框架 vue init webpack-simple vue-movie ...

  3. 基于vue2.0的在线电影APP,

    基于vue2.0构建的在线电影网[film],webpack + vue + vuex + vue-loader + keepAlive + muse-ui + cordova 全家桶,cordova ...

  4. 基于vue2.0的分页组件开发

    今天安排的任务是写基于vue2.0的分页组件,好吧,我一开始是觉得超级简单的,但是越写越写不出来,写的最后乱七八糟的都不知道下句该写什么了,所以重新捋了思路,小结一下- 首先写组件需要考虑: 要从父组 ...

  5. vue-swiper 基于Vue2.0开发 轻量、高性能轮播插件

    vue-swiper 基于 Vue2.0 开发,基本满足大部分功能 轻量.高性能轮播插件.目前支持 无缝衔接自动轮播.无限轮播.手势轮播 没有引入第三方库,原生 js 封装,打包之后只有 8.2KB ...

  6. 基于vue2.0打造移动商城页面实践 vue实现商城购物车功能 基于Vue、Vuex、Vue-router实现的购物商城(原生切换动画)效果

    基于vue2.0打造移动商城页面实践 地址:https://www.jianshu.com/p/2129bc4d40e9 vue实现商城购物车功能 地址:http://www.jb51.net/art ...

  7. vue2.0 开发实践总结之入门篇

    vue2.0 据说也出了很久了,博主终于操了一次实刀. 整体项目采用  vue +  vue-router +  vuex (传说中的vue 全家桶 ),构建工具使用尤大大推出的vue-cli 后续文 ...

  8. 饿了么基于Vue2.0的通用组件开发之路(分享会记录)

    Element:一套通用组件库的开发之路 Element 是由饿了么UED设计.饿了么大前端开发的一套基于 Vue 2.0 的桌面端组件库.今天我们要分享的就是开发 Element 的一些心得. 官网 ...

  9. 基于vue2.0 +vuex+ element-ui后台管理系统:包括本地开发调试详细步骤

    效果演示地址, github地址: demo演示:         1.About 此项目是 vue2.0 + element-ui + node+mongodb 构建的后台管理系统,所有的数据都是从 ...

随机推荐

  1. 循环神经网络 RNN

    随着科学技术的发展以及硬件计算能力的大幅提升,人工智能已经从几十年的幕后工作一下子跃入人们眼帘.人工智能的背后源自于大数据.高性能的硬件与优秀的算法的支持.2016年,深度学习已成为Google搜索的 ...

  2. Codeforces 950.E Data Center Maintenance

    E. Data Center Maintenance time limit per test 1 second memory limit per test 512 megabytes input st ...

  3. C++模式设计-多线程下的单例模式

    1 教科书里的单例模式 我们都很清楚一个简单的单例模式该怎样去实现:构造函数声明为private或protect防止被外部函数实例化,内部保存一个private static的类指针保存唯一的实例,实 ...

  4. Hadoop YARN 的工作流程简述

    1.Client 向 YARN 提交应用程序,其中包括 ApplicationMaster 程序及启动 ApplicationMaster 命令2.ResourceManager 为该 Applica ...

  5. 配置:heartbeat+nginx+mysqld+drbd高可用笔记(OK)

    参考资料:http://www.centoscn.com/CentosServer/cluster/2015/0605/5604.html   背景需求: 使用heartbeat来做HA高可用,并且把 ...

  6. shizhong

    <script charset="Shift_JIS" src="http://chabudai.sakura.ne.jp/blogparts/honehonecl ...

  7. Tensorflow BatchNormalization详解:4_使用tf.nn.batch_normalization函数实现Batch Normalization操作

    使用tf.nn.batch_normalization函数实现Batch Normalization操作 觉得有用的话,欢迎一起讨论相互学习~Follow Me 参考文献 吴恩达deeplearnin ...

  8. OpenCV---Numpy数组的使用以及创建图片

    一:对头像的所有像素进行访问,并UI图像进行像素取反 (一)for循环取反 import cv2 as cv import numpy as np def access_pixels(image): ...

  9. 数学&动态规划:期望DP

    BZOJ3036 给定一张有向无环图,起点为1,终点为N,每个点i有ki条出边,从每个点走其中一条出边的概率是1/ki,求从1到N的期望步数 我们注意到一点,走每条边都是等概率的,那么就相当于 给定一 ...

  10. jieba文本分词,去除停用词,添加用户词

    import jieba from collections import Counter from wordcloud import WordCloud import matplotlib.pyplo ...