const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require("clean-webpack-plugin");
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const autoprefixer = require('autoprefixer');
const outputDirectory = "build";
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, outputDirectory),
filename: 'index.js',
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['react']
}
}
]
},
{
test: /\.(sa|sc|c)ss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: "css-loader",
options: {
sourceMap: true
}
},
{
loader: 'postcss-loader',
options: {
plugins: [
autoprefixer({
Browserslist: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9', // React doesn't support IE8 anyway
]
})
],
sourceMap: true
}
},
{
loader: "sass-loader",
options: {
sourceMap: true
}
}
]
})
},
{
test: /\.(cur|ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
use: {
loader: 'file-loader',
query: {
name: '[name].[hash:8].[ext]',
outputPath: './assets/media/',
publicPath: '/'
}
}
},
{
test: /\.(mp4|webm|wav|mp3|m4a|aac|oga)(\?.*)?$/,
use: {
loader: 'url-loader',
query: {
limit: 10000,
name: '[name].[hash:8].[ext]',
outputPath: './assets/media/',
publicPath: '/'
}
}
}
]
},
plugins: [
new CleanWebpackPlugin([outputDirectory]),
new ExtractTextPlugin({
filename: 'assets/css/[name].[contenthash:8].css'
}),
// new HtmlWebpackPlugin({
// template: './public/index.html',
// title: 'Production',
// favicon: "./public/favicons/favicon.ico"
// })
]
};