-
-
Save ohmree/bb701a5e44b6c258a38bd0e497455d17 to your computer and use it in GitHub Desktop.
Snowpack config for Phoenix and PostCSS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config :my_app, MyAppWeb.Endpoint, | |
http: [port: 4000], | |
debug_errors: true, | |
code_reloader: true, | |
check_origin: false, | |
watchers: [ | |
node: [ | |
"node_modules/.bin/npm-run-all", | |
"watch", | |
cd: Path.expand("../assets", __DIR__) | |
] | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyAppWeb.Endpoint do | |
# ... | |
plug Plug.Static, | |
at: "/", | |
from: :my_app, | |
gzip: false, | |
only: ~w(css fonts images js favicon.ico robots.txt _snowpack) | |
# ... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"repository": {}, | |
"description": " ", | |
"license": "MIT", | |
"scripts": { | |
"deploy": "NODE_ENV=production snowpack build", | |
"watch": "NODE_ENV=development snowpack build" | |
}, | |
"dependencies": { | |
"nprogress": "^0.2.0", | |
"phoenix": "file:../deps/phoenix", | |
"phoenix_html": "file:../deps/phoenix_html", | |
"phoenix_live_view": "file:../deps/phoenix_live_view" | |
}, | |
"devDependencies": { | |
"@snowpack/plugin-postcss": "^1.1.0", | |
"autoprefixer": "^10.2.0", | |
"npm-run-all": "^4.1.5", | |
"postcss": "^8.2.2", | |
"postcss-cli": "^8.3.1", | |
"snowpack": "^3.0.5", | |
"tailwindcss": "^2.0.2" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const glob = require("glob"); | |
const isProduction = process.env.NODE_ENV == "production" | |
const vendorJs = glob.sync("vendor/**") | |
const jsFiles = vendorJs.concat(["js/app.js"]) | |
/** @type { import("snowpack").SnowpackUserConfig } */ | |
module.exports = { | |
mount: { | |
"js": "/js", | |
[vendorJs]: "/js", | |
"css": "/css", | |
"static": "/" | |
}, | |
optimize: { | |
entrypoints: jsFiles, | |
bundle: isProduction, | |
splitting: true, | |
treeshake: isProduction, | |
minify: isProduction, | |
target: "es2017" | |
}, | |
plugins: [ | |
"@snowpack/plugin-postcss" | |
], | |
packageOptions: { | |
knownEntrypoints: jsFiles, | |
}, | |
buildOptions: { | |
out: "../priv/static", | |
watch: !isProduction, | |
sourcemap: !isProduction, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment