Skip to content

Instantly share code, notes, and snippets.

@mikenewbuild
Created February 15, 2022 14:45
Show Gist options
  • Save mikenewbuild/2eaddfb3f5bbca0d1d07908c61725daf to your computer and use it in GitHub Desktop.
Save mikenewbuild/2eaddfb3f5bbca0d1d07908c61725daf to your computer and use it in GitHub Desktop.
Esbuild config for Shopify Themes
import esbuild from "esbuild";
import { sassPlugin } from "esbuild-sass-plugin";
import postcss from "postcss";
import autoprefixer from "autoprefixer";
import postcssPresetEnv from "postcss-preset-env";
esbuild
.build({
entryPoints: {
theme: "src/scripts/theme.js",
},
bundle: true,
outdir: "assets",
target: ["es2018"],
plugins: [
sassPlugin({
async transform(source, resolveDir) {
const { css } = await postcss([
autoprefixer,
postcssPresetEnv({ stage: 0 }),
]).process(source, { from: undefined });
return css;
},
}),
],
minify: true,
watch: true,
sourcemap: true,
})
.then(() => {
console.log("Watching files...");
})
.catch((e) => console.error(e.message));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment