Skip to content

Instantly share code, notes, and snippets.

@Birowsky
Last active November 10, 2016 22:32
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 Birowsky/d03db1083a05e02316a077b7bb5b84fe to your computer and use it in GitHub Desktop.
Save Birowsky/d03db1083a05e02316a077b7bb5b84fe to your computer and use it in GitHub Desktop.
Webpack config
var path = require('path');
var HtmlWebpackPlugin = require( 'html-webpack-plugin' );
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
context: path.resolve('src/scripts'), //https://webpack.github.io/docs/configuration.html#context
entry: [
'./app'
],
output: {
path: path.resolve('builds/dev'),
publicPath: '/',
filename: 'bundle.js'
},
devServer: {
// contentBase: 'src'
proxy: {
'/api': {
target: 'http://dev.cscade.com',
secure: false,
}
},
historyApiFallback: true //pushState
},
module: {
loaders: [
loader({
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css!postcss')
}),
loader({
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style', 'css!postcss!sass')
}),
loader({
test: /\.(es6|js)$/,
loader: 'babel'
})
]
},
postcss: () => [
cqProlyfill(),
autoprefixer(),
],
resolve: {
extensions: ['', '.js', '.es6'],
alias: {
Elm: path.resolve('builds/intellij/scripts/elm-program.js')
}
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve('src/index.html'),
inject: 'body',
filename: 'index.html'
}),
new webpack.DefinePlugin({
__IS_HYBRID__: JSON.stringify(false)
}),
new ExtractTextPlugin('styles.css')
]
};
function autoprefixer() {
return require('autoprefixer')({
browsers: ['last 3 versions']
});
}
function cqProlyfill() {
return require('cq-prolyfill/postcss-plugin')();
}
function loader(config) {
return Object.assign(config, {
exclude: [/node_modules/,/builds/, /elm-stuff/],
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment