Last active
November 23, 2016 15:05
-
-
Save bbss/ffebfaa6bbd9fa1d8e6f6c6842e4add5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Webpack config for creating the production bundle. | |
require('babel-polyfill'); | |
require('es6-promise').polyfill(); | |
var path = require('path'); | |
var webpack = require('webpack'); | |
var ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
var strip = require('strip-loader'); | |
var VersionFile = require('webpack-version-file-plugin'); | |
var webpackFileTransformPlugin = require('webpack-file-transform-plugin') | |
var assetsPath = path.join(__dirname, '../dist'); | |
var bourbon = require('node-bourbon').includePaths; | |
module.exports = { | |
devtool: null, | |
context: path.resolve(__dirname, '..'), | |
entry: { | |
'main': './src/js/client.js', | |
'vendor': ['falcor', 'react', 'lodash', 'd3', 'ramda', 'immutable'] | |
}, | |
output: { | |
path: assetsPath, | |
filename: '[name]-[hash].js', | |
chunkFilename: 'chunk-[name]-[chunkhash].js', | |
publicPath: '/dist/' | |
}, | |
module: { | |
loaders: [ | |
{ test: /\.js$/, exclude: /node_modules/, loaders: [strip.loader('debug'), 'babel']}, | |
{ test: /\.json$/, loader: 'json-loader' }, | |
{ test: /\.css$/, loader: 'style!css' }, | |
{ test: /\.scss$/, loader: ExtractTextPlugin.extract('style', 'css!autoprefixer?browsers=last 2 version!sass?includePaths[]=' + bourbon) }, | |
{ test: /\.(woff|ttf|eot)$/, loader: 'url-loader?limit=8000' } | |
] | |
}, | |
debug: true, | |
progress: true, | |
resolve: { | |
modulesDirectories: [ | |
'src/js', | |
'node_modules', | |
'node_modules/leaflet/dist' | |
], | |
extensions: ['', '.json', '.js'] | |
}, | |
plugins: [ | |
// css files from the extract-text-plugin loader | |
new ExtractTextPlugin('[name]-[chunkhash].css', { allChunks: true }), | |
new webpack.DefinePlugin({ | |
__CLIENT__: true, | |
__SERVER__: false, | |
__DEVELOPMENT__: false, | |
__DEVTOOLS__: false, | |
__TEST__: false | |
}), | |
// ignore dev config | |
new webpack.IgnorePlugin(/\.\/dev/, /\/config$/), | |
// set global vars | |
new webpack.DefinePlugin({ | |
'process.env': { | |
// Useful to reduce the size of client-side libraries, e.g. react | |
NODE_ENV: JSON.stringify('production'), | |
SERVER: JSON.stringify(process.env.SERVER) | |
} | |
}), | |
// optimizations | |
new webpack.optimize.OccurenceOrderPlugin(), | |
new webpack.optimize.UglifyJsPlugin({ | |
beautify: false, | |
comments: false, | |
minimize: true, | |
sourceMap: false, | |
compress: { | |
warnings: false, | |
dead_code: true, | |
} | |
}), | |
new webpack.optimize.CommonsChunkPlugin('vendor', '[name]-[hash].js'), | |
// add version file | |
new VersionFile({ | |
templateString: "build-date: " + new Date(), | |
}), | |
new webpackFileTransformPlugin({ | |
path: path.join(__dirname, '../version.txt'), | |
outputPath: path.join(__dirname, '../dist/version.txt'), | |
}), | |
] | |
}; |
This file contains hidden or 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
. | |
└── js | |
├── actions | |
├── app | |
├── build | |
├── charts | |
├── client.js | |
├── components | |
├── config.js this file gets resolved | |
├── constants | |
files in this directory can get resolved in js/server.js | |
├── falcor | |
├── helpers | |
├── reducers | |
├── redux | |
├── routes | |
├── selector | |
├── server.js | |
├── start-server.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment