Last active
November 10, 2016 22:32
-
-
Save Birowsky/d03db1083a05e02316a077b7bb5b84fe to your computer and use it in GitHub Desktop.
Webpack config
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
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