Skip to content

Instantly share code, notes, and snippets.

@bambielli
Last active April 30, 2017 18:52
Show Gist options
  • Save bambielli/4d3ebacd263661aa96bdf10140aaf1b7 to your computer and use it in GitHub Desktop.
Save bambielli/4d3ebacd263661aa96bdf10140aaf1b7 to your computer and use it in GitHub Desktop.
Webpack Config for Blog Posts (www.bambielli.com)
const webpack = require('webpack')
const path = require('path')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const buildPath = '/build/'
module.exports = {
entry: {
bundle: ['./static-assets/index.js'],
vendor: ['react'],
'global-css': 'static-assets/less/global-css.less'
},
output: {
filename: 'js/[name].min.js',
path: path.join(__dirname, buildPath),
publicPath: '/assets/'
},
devServer: {
contentBase: path.join(__dirname, buildPath),
port: 8445,
https: true,
proxy: {
'/api2': {
target: 'https://new-api-domain.com',
secure: false,
pathRewrite: {"^/api2", ""}
}
},
module: {
rules: [
{
test: /\.js$/,
use: 'eslint-loader',
enforce: 'pre',
exclude: /node_modules/
},
{
test: /\.js$/,
use: 'babel-loader',
exclude: [
/node_modules/,
/spec\.js$/
]
},
{
test: /\.less$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader!less-loader'
}),
exclude: /node_modules/
}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
names: ['vendor'],
filename: 'js/[name].min.js',
minChunks: Infinity
}),
new ExtractTextPlugin('css/[name].min.css')
]
}
/*
output bundles are:
bundle.min.js
vendor.min.js
global-css.min.js
bundle.min.css
global-css.min.css
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment