Created
September 15, 2017 09:17
-
-
Save unfalse/f165a012c12d08637f0526299bb88979 to your computer and use it in GitHub Desktop.
webpack production config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "", | |
"start": "node server", | |
"build": "rimraf public && webpack --config ./webpack.production.config.js --progress --profile --colors --display-error-details", | |
"eslint": "eslint ." | |
}, | |
"dependencies": { | |
"babel-polyfill": "^6.26.0", | |
"file-loader": "^0.9.0", | |
"lodash": "^4.17.4", | |
"material-ui": "0.17.1", | |
"moment": "^2.18.1", | |
"react": "^15.0.2", | |
"react-bootstrap": "^0.30.8", | |
"react-click-outside": "^2.3.1", | |
"react-dnd": "^2.4.0", | |
"react-dnd-html5-backend": "^2.3.0", | |
"react-dom": "^15.0.2", | |
"react-hot-loader": "^3.0.0-beta.2", | |
"react-redux": "^4.4.5", | |
"react-router": "^3.0.3", | |
"react-router-redux": "^4.0.4", | |
"react-tap-event-plugin": "^2.0.1", | |
"react-tooltip": "^3.2.10", | |
"redux": "^3.5.2", | |
"redux-thunk": "^2.2.0", | |
"underscore": "^1.8.3" | |
}, | |
"devDependencies": { | |
"autoprefixer": "^6.3.6", | |
"babel-core": "^6.26.0", | |
"babel-eslint": "^7.2.3", | |
"babel-loader": "^7.1.2", | |
"babel-preset-env": "^1.6.0", | |
"css-loader": "^0.23.1", | |
"eslint": "^4.6.1", | |
"eslint-loader": "^1.9.0", | |
"eslint-plugin-react": "^5.0.1", | |
"exports-loader": "^0.6.4", | |
"extract-text-webpack-plugin": "^3.0.0", | |
"html-webpack-plugin": "^2.16.1", | |
"imports-loader": "^0.7.1", | |
"json-loader": "^0.5.4", | |
"node-sass": "^3.7.0", | |
"postcss-loader": "^0.9.1", | |
"prop-types": "^15.5.10", | |
"react-addons-test-utils": "^15.0.2", | |
"rimraf": "^2.5.2", | |
"sass-loader": "^3.2.0", | |
"stats-webpack-plugin": "^0.3.1", | |
"style-loader": "^0.13.1", | |
"stylus": "^0.54.5", | |
"stylus-loader": "^2.5.1", | |
"url-loader": "^0.5.7", | |
"webpack": "^3.5.6", | |
"webpack-dev-server": "^2.8.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var path = require('path'); | |
var webpack = require('webpack'); | |
var HtmlWebpackPlugin = require('html-webpack-plugin'); | |
var ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
var StatsPlugin = require('stats-webpack-plugin'); | |
module.exports = { | |
// The entry file. All your app roots fromn here. | |
entry: [ 'babel-polyfill', path.join(__dirname, 'app/jsc/index.js') ], | |
// Where you want the output to go | |
output: { | |
path: path.resolve(__dirname, '/../web_build/'), | |
filename: '[name]-[hash].min.js', | |
publicPath: '/' | |
}, | |
plugins: [ | |
// handles creating an index.html file and injecting assets. necessary because assets | |
// change name because the hash part changes. We want hash name changes to bust cache | |
// on client browsers. | |
new HtmlWebpackPlugin({ | |
template: 'app/index.tpl.html', | |
inject: 'body', | |
filename: 'indexAdmin.html' | |
}), | |
// extracts the css from the js files and puts them on a separate .css file. this is for | |
// performance and is used in prod environments. Styles load faster on their own .css | |
// file as they dont have to wait for the JS to load. | |
new ExtractTextPlugin('[name]-[hash].min.css'), | |
// handles uglifying js | |
new webpack.optimize.UglifyJsPlugin({ | |
compressor: { | |
warnings: false, | |
screw_ie8: true | |
} | |
}), | |
// creates a stats.json | |
new StatsPlugin('webpack.stats.json', { | |
source: false, | |
modules: false | |
}), | |
// plugin for passing in data to the js, like what NODE_ENV we are in. | |
new webpack.DefinePlugin({ | |
'process.env.NODE_ENV': JSON.stringify('production') | |
}), | |
new webpack.ProvidePlugin({ | |
Promise: 'imports-loader?this=>global!exports-loader?global.Promise!es6-promise', | |
fetch: 'imports-loader?this=>global!exports-loader?global.fetch!whatwg-fetch', | |
React: 'react' | |
}) | |
], | |
module: { | |
// loaders handle the assets, like transforming sass to css or jsx to js or stylus to css. | |
rules: [ | |
{ | |
test: /\.js$/, | |
enforce: "pre", | |
exclude: /node_modules/, | |
loader: 'eslint-loader' | |
}, | |
{ | |
test: /\.js?$/, | |
exclude: /node_modules/, | |
loaders: 'babel-loader' | |
}, | |
//TODO If we want,we can use scss later | |
// { | |
// test: /\.scss$/, | |
// // we extract the styles into their own .css file instead of having | |
// // them inside the js. | |
// loader: ExtractTextPlugin.extract('style', 'css?modules&localIdentName=[name]---[local]---[hash:base64:5]!sass') | |
// }, | |
{ | |
test: /\.styl/, | |
loader: ExtractTextPlugin.extract("style-loader", "css-loader!stylus-loader?resolve url") | |
}, | |
{ | |
test: /\.woff(2)?(\?[a-z0-9#=&.]+)?$/, | |
loader: 'url-loader?limit=10000&mimetype=application/font-woff' | |
}, | |
{ | |
test: /\.(ttf|eot|svg|img|png|gif|jpg)(\?[a-z0-9#=&.]+)?$/, | |
loader: 'file-loader?name=[path][name].[ext]' | |
}, | |
{ | |
loader: 'postcss-loader', | |
options: { | |
plugins: (loader) => [ | |
require('autoprefixer')() | |
] | |
} | |
} | |
] | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment