Skip to content

Instantly share code, notes, and snippets.

@jayhill90
Created November 13, 2019 13:56
Show Gist options
  • Save jayhill90/d66bb332dffed52e414e72fa09fc3da5 to your computer and use it in GitHub Desktop.
Save jayhill90/d66bb332dffed52e414e72fa09fc3da5 to your computer and use it in GitHub Desktop.
A basic webpack config file for WordPress themes to compile JS, SCSS and Font files
const path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
entry: ['./src/js/index.js', './src/scss/index.scss'],
output: {
filename: './build/js/index.js',
path: path.resolve(__dirname),
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: ['babel-preset-env']
}
}
},
{
test: /\.(sc|c)ss$/,
use: [
{
loader: MiniCssExtractPlugin.loader
},
{
loader: "css-loader",
},
{
loader: "postcss-loader",
options: {
ident: 'postcss',
plugins: [
require('postcss-apply'),
require('tailwindcss'),
require('autoprefixer')
]
}
},
{
loader: "sass-loader",
options: {
implementation: require("sass")
}
}
]
},
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
loader: "file-loader?name=/build/fonts/[name].[ext]",
options: {
name: 'build/fonts/[name].[ext]',
publicPath: function(url) {
return url.replace(/build/, '..')
},
}
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: "./build/scss/index.css"
})
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment