postcss with webpack
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const cssExtractPlugin = new ExtractTextPlugin('/css/[name]_[contenthash].css');
var autoprefixer = require('autoprefixer');
var precss = require('precss');
const conf = {
entry: {
'main': ['./assets/js/main.js']
},
output: {
hash: true,
path: path.join(__dirname, 'output'),
publicPath: '',
filename: '/js/[name]_[hash].js',
chunkFilename: '/js/chunk_[id]_[chunkhash].js'
},
module: {
loaders: [
{
test: /\.css$/,
loader: cssExtractPlugin.extract("style-loader", "css-loader!postcss-loader")
}
]
},
postcss: function () {
return [
autoprefixer,
precss
];
},
plugins: [
cssExtractPlugin,
new HtmlWebpackPlugin({
template: 'index.html',
filename: 'index.html',
inject: 'body',
chunks: ['main']
})
],
devServer: {
port: '9999'
}
};
module.exports = conf;