1 Star 0 Fork 89

走一会歇一会/Peer-To-Peer

forked from CodingMr.Zhou/Peer-To-Peer 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
webpack.config.js 4.53 KB
一键复制 编辑 原始数据 按行查看 历史
zhouquan 提交于 2015-06-19 17:48 . 修改webpack 配置文件
var webpack = require("webpack");
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var env_prod = process.env.NODE_ENV === 'production';
console.log('NODE_ENV:::::' + process.env.NODE_ENV);
var output_options = {
path: __dirname + '/web-src/assets/',
filename: '[name].js',
chunkFilename: '[name].js',
publicPath: '/assets/'
};
var plugins_options = [
new webpack.optimize.CommonsChunkPlugin("vendor", "vendor.js"),
new ExtractTextPlugin('[name].css', {allChunks: true}),
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify(env_prod ? "production" : 'develop')
}
}),
new HtmlWebpackPlugin({
title: 'Home · Peer To Peer',
filename: '../../views/portal.jade',
template: 'web-src/html/base.jade',
chunks: ['main', 'vendor'],
minify: env_prod ? {
removeComments: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeRedundantAttributes: true,
removeEmptyAttributes: true
} : false,
hash: true
})
];
if(!env_prod){
plugins_options.push(new webpack.SourceMapDevToolPlugin({
test: /\.(js|css)($|\?)/i,
filename: 'maps/[file].map'
}));
}
if(env_prod){
plugins_options.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}));
}
var preLoaders_options = [];
if(!env_prod){
preLoaders_options.push({
test: /\.js$/, // include .js files
exclude: /node_modules/, // exclude any and all files in the node_modules folder
loader: "jshint-loader"
});
}
var postLoaders_options = [];
if(env_prod) {
postLoaders_options.push({
loader: 'transform?envify'
});
}
module.exports = {
entry: {
main: __dirname + '/web-src/js/components/page/Main.react.jsx',
vendor: [
'react',
'react/addons',
'react-router',
'react-bootstrap',
'react-tween-state',
'keymirror',
'flux',
'lodash',
'immutable',
'events',
'classnames',
'jwt-decode',
'inherits',
'reqwest',
'when',
'store']
},
output: output_options,
plugins: plugins_options,
debug: !env_prod,
cache: !env_prod,
watch: !env_prod,
module: {
preLoaders: preLoaders_options,
postLoaders: postLoaders_options,
loaders: [{
test: /\.jsx$/,
exclude: /node_modules/,
loader: 'jsx-loader?insertPragma=React.DOM&harmony!strict'
}, {
test: /\.js$/,
exclude: /node_modules/,
loader: 'strict'
}, {
test: /\.css$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader?sourceMap!autoprefixer-loader")
},{
test: /\.less$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader?sourceMap!autoprefixer-loader!less-loader")
}, {
test: /\.(woff|woff2|ttf|eot|svg)$/,
loader: "url-loader"
}, {
test: /\.(png|jpg|gif)$/,
loader: 'url-loader?limit=8192'
}]
},
jshint: {
// This option prohibits the use of explicitly undeclared variables. This option is very useful for spotting leaking and mistyped variables.
undef: true,
// This option defines globals exposed by modern browsers: all the way from good old document and navigator to the HTML5 FileReader and other new developments in the browser world.
browser: true,
// This option defines globals that are usually used for logging poor-man's debugging: console, alert, etc. It is usually a good idea to not ship them in production because, for example, console.log breaks in legacy versions of Internet Explorer.
devel: false,
// This option warns when you define and never use your variables. It is very useful for general code cleanup, especially when used in addition to undef.
unused: true,
// jshint errors are displayed by default as warnings
// set emitErrors to true to display them as errors
emitErrors: true,
// jshint to not interrupt the compilation
// if you want any file with jshint errors to fail
// set failOnHint to true
failOnHint: true
},
resolve: {
extensions: ['', '.js', '.jsx']
}
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/winiceo/Peer-To-Peer.git
git@gitee.com:winiceo/Peer-To-Peer.git
winiceo
Peer-To-Peer
Peer-To-Peer
master

搜索帮助