30 Star 111 Fork 33

吴彦文/dianpinPlus

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
webpack.server.js 2.67 KB
一键复制 编辑 原始数据 按行查看 历史
wuyanwen 提交于 2017-09-07 13:31 . 初始化提交
const webpack = require('webpack');
const path = require('path');
const htmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
require('./mockServer/server.js');
module.exports = {
entry:{
app: path.resolve(__dirname, 'app/index.jsx'),
// 将 第三方依赖 单独打包
vendor: [
'react',
'react-dom',
'react-redux',
'react-router-dom',
'redux',
'es6-promise',
'whatwg-fetch',
'prismjs',
'fastclick'
]
},
output:{
path:__dirname+"./public",
filename: "script/[name].[hash:8].js",
publicPath: "/",
chunkFilename: "script/[name].[chunkhash:8].js"
},
resolve:{
extensions:['.js','.jsx']
},
module:{
loaders:[
{
test:/\.(js|jsx)$/,
exclude:/node_modules/,
loader:'babel-loader',
query:{
"presets":['react','es2015']
}
},
{
test: /\.less$/,
exclude: /node_modules/,
loader: ExtractTextPlugin.extract({
fallback:'style-loader',
use:'css-loader?modules&localIdentName=[local]-[hash:base64:8]!resolve-url-loader!postcss-loader!less-loader'
})
},
{
test: /\.css$/,
exclude: /node_modules/,
loader: ExtractTextPlugin.extract({
fallback:'style-loader',
use:'css-loadermodules&localIdentName=[local]-[hash:base64:8]!resolve-url-loader!postcss-loader'
})
},
{
test:/\.(png|gif|jpg|jpeg|bmp)$/,
loader:'url-loader?limit=1&name=images/[name].[hash:8].[ext]'
}, // 限制大小5kb
{
test:/\.(woff|woff2|svg|ttf|eot)($|\?)/,
loader:'file-loader?name=fonts/[name].[hash:8].[ext]'
} // 限制大小小于5k
]
},
plugins:[
new htmlWebpackPlugin({
favicon:'./app/static/images/favicon.jpg',
template:'./app/index.html'
}),
new webpack.LoaderOptionsPlugin({
options:{
postcss:()=>{
return [
require('autoprefixer')({
browsers: ['last 10 versions','ie>=8','>1% in CN']
})
]
}
}
}),
// 分离CSS
new ExtractTextPlugin('style/[name].[chunkhash:8].css'),
new webpack.HotModuleReplacementPlugin(),
// 提供公共代码
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
filename: 'script/[name].[hash:8].js'
})
],
devServer:{
proxy:{
'/api':{
target:"http://localhost:3000",
secure:false
}
},
contentBase:'./public',
historyApiFallback:true,
inline:true,
hot:true
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/wuyanwen/dianpinPlus.git
git@gitee.com:wuyanwen/dianpinPlus.git
wuyanwen
dianpinPlus
dianpinPlus
master

搜索帮助