当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
1 Star 0 Fork 2

Persar/mmall-fe
关闭

forked from Megan/mmall-fe
关闭
 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
webpack.config.js 3.92 KB
一键复制 编辑 原始数据 按行查看 历史
带娃儿先走 提交于 2017-12-11 23:07 . 更新 webpack.config.js
//2017年10月6日13:22:15
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
//环境变量的配置
var WEBPACK_ENV = process.env.WEBPACK_ENV || 'dev';
console.log(WEBPACK_ENV);
//获取html-webpack-plugin参数的方法
var getHtmlConfig = function(name,title){
return{
template : './src/view/'+name+'.html',
filename : 'view/'+name+'.html',
favicon : './favicon.ico',
title : title,
inject : true,
hash : true,
chunks : ['common',name]
}
}
//webpack config
var config={
entry:{
'common' : ['./src/page/common/index.js'],
'index' : ['./src/page/index/index.js'],
'list' : ['./src/page/list/index.js'],
'detail' : ['./src/page/detail/index.js'],
'home' : ['./src/page/home/index.js'],
'about' : ['./src/page/about/index.js'],
'cart' : ['./src/page/cart/index.js'],
'order-confirm' : ['./src/page/order-confirm/index.js'],
'order-detail' : ['./src/page/order-detail/index.js'],
'payment' : ['./src/page/payment/index.js'],
'order-list' : ['./src/page/order-list/index.js'],
'user-login' : ['./src/page/user-login/index.js'],
'user-register' : ['./src/page/user-register/index.js'],
'user-pass-reset' : ['./src/page/user-pass-reset/index.js'],
'user-center' : ['./src/page/user-center/index.js'],
'user-center-update' : ['./src/page/user-center-update/index.js'],
'user-pass-update' : ['./src/page/user-pass-update/index.js'],
'result' : ['./src/page/result/index.js']
},
output:{
path : __dirname +'/dist/',
publicPath : 'dev' === WEBPACK_ENV ? '/dist/' : '//s.meganmmall.com/mmall-fe/dist/',
filename : 'js/[name].js'
},
externals:{
'jquery':'window.jQuery'
},
module:{
loaders:[
{test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader","css-loader")},
{test: /\.(gif|png|jpg|woff|svg|eot|ttf)\??.*$/, loader: 'url-loader?limit=1000&name=resource/[name].[ext]' },
{
test: /\.string$/,
loader: 'html-loader',
query : {
minimize : true,
removeAttributeQuotes : false
}
}
]
},
resolve : {
alias : {
node_modules : __dirname + '/node_modules',
util : __dirname + '/src/util',
page : __dirname + '/src/page',
service : __dirname + '/src/service',
image : __dirname + '/src/image',
}
},
plugins:[
//独立通用模块到js/base.js
new webpack.optimize.CommonsChunkPlugin({
name:'common',
filename:'js/base.js'
}),
//把css单独打包到文件里
new ExtractTextPlugin('css/[name].css'),
//html模板的处理
new HtmlWebpackPlugin(getHtmlConfig('index' ,'首页')),
new HtmlWebpackPlugin(getHtmlConfig('home' ,'首页')),
new HtmlWebpackPlugin(getHtmlConfig('list' ,'商品列表')),
new HtmlWebpackPlugin(getHtmlConfig('detail' ,'商品详情')),
new HtmlWebpackPlugin(getHtmlConfig('user-login' ,'用户登录')),
new HtmlWebpackPlugin(getHtmlConfig('user-register' ,'用户注册')),
new HtmlWebpackPlugin(getHtmlConfig('user-pass-reset' ,'找回密码')),
new HtmlWebpackPlugin(getHtmlConfig('user-center' ,'个人中心')),
new HtmlWebpackPlugin(getHtmlConfig('user-center-update' ,'修改个人信息')),
new HtmlWebpackPlugin(getHtmlConfig('about' ,'关于MMall')),
new HtmlWebpackPlugin(getHtmlConfig('user-pass-update' ,'修改密码')),
new HtmlWebpackPlugin(getHtmlConfig('cart' ,'购物车')),
new HtmlWebpackPlugin(getHtmlConfig('order-confirm' ,'订单确认')),
new HtmlWebpackPlugin(getHtmlConfig('order-list' ,'订单列表')),
new HtmlWebpackPlugin(getHtmlConfig('order-detail' ,'订单详情')),
new HtmlWebpackPlugin(getHtmlConfig('payment' ,'订单支付')),
new HtmlWebpackPlugin(getHtmlConfig('result' ,'操作结果'))
]
};
if('dev' == WEBPACK_ENV){
config.entry.common.push('webpack-dev-server/client?http://localhost:8088/');
}
module.exports=config;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/PersarZhao/mmall-fe.git
git@gitee.com:PersarZhao/mmall-fe.git
PersarZhao
mmall-fe
mmall-fe
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385