Skip to content

Instantly share code, notes, and snippets.

@1littleOrc
Created March 28, 2018 14:54
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 1littleOrc/07663335468c3c9471a889e00aa43420 to your computer and use it in GitHub Desktop.
Save 1littleOrc/07663335468c3c9471a889e00aa43420 to your computer and use it in GitHub Desktop.
webpack = require('webpack');
path = require('path');
const HtmlWebPackPlugin = require("html-webpack-plugin");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
entry: './src/index.js',
output: {
path: __dirname + '/dist',
filename: 'main.js'
},
module: {
rules: [{
test: /\.(png|jpg|gif)$/,
use: [{
loader: 'file-loader',
options: {}
}]
},
{
test: /\.svg$/,
loader: 'svg-inline-loader'
},
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
},
{
test: /\.pug$/,
use: [{
loader: 'html-loader'
},
{
loader: 'pug-html-loader',
options: {}
}
]
},
{
test: /\.html$/,
use: [{
loader: "html-loader",
options: {
// minimize: true
}
}]
},
{
test: /\.(css|sass|scss)$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 2,
sourceMap: true
}
},
{
loader: 'postcss-loader',
options: {
plugins: () => [
require('autoprefixer')
],
sourceMap: true
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true
}
}
]
}
]
},
plugins: [
new HtmlWebPackPlugin({
filename: 'index.html',
template: './src/index.pug'
}),
new HtmlWebPackPlugin({
filename: 'buy.html',
template: './src/buy.pug',
chunks: []
}),
new HtmlWebPackPlugin({
filename: 'carousel.html',
template: './src/carousel.pug',
chunks: []
}),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css"
})
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment