I know - I was kind of heading there:
// package.json
{
"repository": {},
"license": "MIT",
"scripts": {
"watch": "npm-run-all --parallel watch:*",
"build:assets": "rsync -r ./web/static/assets/ ./priv/static",
"build:css": "cat ./web/static/css/phoenix.css ./web/static/css/app.css > ./priv/static/css/app.css",
"watch:css": "watch 'npm run build:css' ./web/static/css/",
"build:js": "rollup -c",
"watch:js": "rollup -c -w",
"build": "npm run build:js && npm run build:css"
},
"dependencies": {
"phoenix": "file:deps/phoenix",
"phoenix_html": "file:deps/phoenix_html"
},
"devDependencies": {
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-latest": "^6.24.1",
"npm-run-all": "^4.0.2",
"rollup": "^0.41.6",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-watch": "^3.2.2",
"watch": "^1.0.2"
}
}
.
// rollup.config.js
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import babel from 'rollup-plugin-babel';
export default {
entry: "web/static/js/app.js",
format: "iife",
plugins: [
resolve({
browser: true,
preferBuiltins: false,
customResolveOptions: {
moduleDirectory: [
"deps/phoenix/priv/static",
"deps/phoenix_html/priv/static"
]
}
}),
commonjs({
ignoreGlobal: true
}),
babel({
exclude: [
'node_modules/**',
'deps/**'
]
// for everything else use .babelrc
})
],
dest: "priv/static/js/app.js"
}
.
# config/dev.exs
...
code_reloader: true,
check_origin: false,
watchers: [node: ["node_modules/npm-run-all/bin/npm-run-all", "--parallel", "watch:*",
cd: Path.expand("../", __DIR__)]]
...
But there don’t seem to the caliber of “one-thing-only” tools that cover the other build aspects the way rollup.js
has got the JavaScript build covered. PostCSS is promising but for example this gets gulp involved to do bundling - not going down that rabbit hole.
Also I think it may be too great a cost to give up on the integration support that Vue seems to have with webpack (even though there seem to be enough people who cringe when they hear “webpack”).