-
-
Save hellpirat/7c07f58ebee2e5a71f25a4378bfe400d to your computer and use it in GitHub Desktop.
Webpack
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
var path = require('path') | |
var webpack = require('webpack') | |
var HtmlWebpackPlugin = require('html-webpack-plugin') | |
var ExtractTextPlugin = require("extract-text-webpack-plugin") | |
module.exports = { | |
plugins: [ | |
new ExtractTextPlugin('/css/style.[hash].css'), | |
new HtmlWebpackPlugin({ | |
title: 'timestock', | |
filename: 'index.html', | |
template: 'src/index.tpl' | |
}) | |
], | |
module: { | |
loaders: [ | |
{ test: /.*(android|apple|ms-icon|favicon|manifest|browserconfig).*$/, loader: 'file?name=favicons/[name].[ext]' }, | |
{ test: /\.json$/, loaders: ['json-loader'] }, | |
{ test: /\.js$/, loaders: ['babel'], include: path.join(__dirname, 'src/scripts') }, | |
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style', 'css', {publicPath: "../"}) }, | |
{ test: /\.(png|jpg)$/, loader: 'file?name=images/[name].[hash].[ext]' }, | |
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: 'file?name=fonts/[name].[hash].[ext]&mimetype=application/font-woff'}, | |
{ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,loader: 'file?name=fonts/[name].[hash].[ext]&mimetype=application/font-woff'}, | |
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'file?name=fonts/[name].[hash].[ext]&mimetype=application/octet-stream'}, | |
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file?name=fonts/[name].[hash].[ext]'}, | |
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'file?name=images/[name].[hash].[ext]&mimetype=image/svg+xml' } | |
] | |
} | |
} |
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
let path = require('path') | |
let webpack = require('webpack') | |
import baseConfig from './webpack.config.base' | |
module.exports = { | |
...baseConfig, | |
entry: { | |
app: './src/scripts/index', | |
vendor: ["jquery", "moment", "react", "react-bootstrap"], | |
}, | |
output: { | |
filename: '/js/[name].[hash].js', | |
path: path.join(__dirname, 'dist'), | |
}, | |
devtool: 'source-map', | |
plugins: [ | |
...baseConfig.plugins, | |
new webpack.optimize.OccurenceOrderPlugin(), | |
new webpack.optimize.DedupePlugin(), | |
new webpack.optimize.CommonsChunkPlugin({ | |
name: "vendor", | |
minChunks: Infinity, | |
}), | |
new webpack.NoErrorsPlugin(), | |
new webpack.DefinePlugin({ | |
'process.env': { | |
'NODE_ENV': JSON.stringify('production') | |
}, | |
}), | |
new webpack.optimize.UglifyJsPlugin({ | |
compressor: { | |
warnings: false | |
}, | |
output: { | |
comments: false | |
} | |
}) | |
], | |
module: { | |
...baseConfig.module, | |
loaders: [ | |
...baseConfig.module.loaders | |
] | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment