Skip to content

Instantly share code, notes, and snippets.

@kevinSuttle
Created September 20, 2016 14:34
Show Gist options
  • Save kevinSuttle/e7df013a87cd4d2dd48c63dd013a0a4c to your computer and use it in GitHub Desktop.
Save kevinSuttle/e7df013a87cd4d2dd48c63dd013a0a4c to your computer and use it in GitHub Desktop.
I just want Sass
const webpack = require('webpack');
const path = require('path');
var customProperties = require("postcss-custom-properties");
var cssApply = require('postcss-apply');
var autoprefixer = require('autoprefixer');
module.exports = env => {
if (!env) env = {}
const addPlugin = (add, plugin) => add ? plugin : undefined;
const ifProd = plugin => addPlugin(env.prod || false, plugin);
const removeEmpty = array => array.filter(i => !!i);
return {
entry: './src/',
output: {
filename: 'ui-primitives.js',
path: path.resolve(__dirname, 'dist'),
pathinfo: !(env.prod || false),
libraryTarget: 'commonjs2'
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel'
},
{ test: /\.css$/, loader: 'style-loader!css-loader!postcss-loader' },
{ test: /\.png$/, loader: 'url-loader?limit=100000' },
{ test: /\.svg$/, loader: 'file-loader' },
],
},
plugins: removeEmpty([
ifProd(new webpack.optimize.DedupePlugin()),
ifProd(new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false,
})),
ifProd(new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"',
},
})),
ifProd(new webpack.optimize.UglifyJsPlugin({
compress: {
screw_ie8: true,
warnings: false,
},
})),
]),
postcss: function () {
return [
require('postcss-npm')(),
customProperties({preserve: true}),
cssApply,
autoprefixer,
]
},
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment