Skip to content

Instantly share code, notes, and snippets.

@hellpirat
Created October 6, 2017 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hellpirat/7c07f58ebee2e5a71f25a4378bfe400d to your computer and use it in GitHub Desktop.
Save hellpirat/7c07f58ebee2e5a71f25a4378bfe400d to your computer and use it in GitHub Desktop.
Webpack
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' }
]
}
}
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