1 Star 2 Fork 3

Pal / React-仿大众点评

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
webpack.config.js 2.65 KB
一键复制 编辑 原始数据 按行查看 历史
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var OpenBrowserPlugin = require('open-browser-webpack-plugin');
// var nodeModulesPath = path.resolve(__dirname, 'node_modules')
// console.log(process.env.NODE_ENV)
function resolve(dir) {
return path.join(__dirname, '..', dir)
}
module.exports = {
entry: path.resolve(__dirname, './src/index.jsx'),
output: {
path: __dirname + '/build',
filename: 'bundle.js',
},
resolve: {
extensions: ['', '.js', '.jsx']
},
module: {
// preLoaders: [
// // 报错 ?????
// {test: /\.(js|jsx)$/, loader: "eslint-loader", exclude:
// /node_modules/} ],
loaders: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel',
},
{
test: /\.less$/,
exclude: /node_modules/,
loader: 'style!css!postcss!less',
},
{
test: /\.css$/,
exclude: /node_modules/,
loader: 'style!css!postcss',
},
{
test: /\.(png|gif|jpg|jpeg|bmp)$/i,
loader: 'url-loader?limit=5000',
}, // 限制大小5kb
{
test: /\.(png|woff|woff2|svg|ttf|eot)($|\?)/i,
loader: 'url-loader?limit=5000',
} // 限制大小小于5k
],
},
eslint: {
configFile: '.eslintrc' // Rules for eslint
},
postcss: [
require('autoprefixer') //调用autoprefixer插件,例如 display: flex
],
plugins: [
// html 模板插件
new HtmlWebpackPlugin({
template: __dirname + '/index.html',
}),
// 热加载插件
new webpack.HotModuleReplacementPlugin(),
// 打开浏览器
new OpenBrowserPlugin({
url: 'http://localhost:8080',
}),
// 可在业务 js 代码中使用 __DEV__ 判断是否是dev模式(dev模式下可以提示错误、测试报告等, production模式不提示)
new webpack.DefinePlugin({
__DEV__: JSON.stringify(JSON.parse((process.env.NODE_ENV == 'dev') || 'false')),
}),
],
devServer: {
proxy: {
// 凡是 `/api` 开头的 http 请求,都会被代理到 localhost:3000 上,由 koa 提供 mock 数据。
// koa 代码在 ./mock 目录中,启动命令为 npm run mock
'/api': {
target: 'http://localhost:3000',
secure: false,
},
},
contentBase: './public', //本地服务器所加载的页面所在的目录
colors: true, //终端中输出结果为彩色
historyApiFallback: true, //不跳转
inline: true, //实时刷新
hot: true // 使用热加载插件 HotModuleReplacementPlugin
},
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/Arteezy112/React-FangDaZhongDianPing.git
git@gitee.com:Arteezy112/React-FangDaZhongDianPing.git
Arteezy112
React-FangDaZhongDianPing
React-仿大众点评
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891