I still can’t manage to get it working, I have my Elm folder under lib/my_app/web/elm
, I have my Main.elm
file as follows:
module HelloWorld exposing (..)
import Html
main =
Html.text "Hello world from Elm!"
My brunch-config.js
is as follows:
exports.config = {
files: {
javascripts: {
joinTo: "js/app.js"
},
stylesheets: {
joinTo: "css/app.css"
},
templates: {
joinTo: "js/app.js"
}
},
conventions: {
assets: /^(static)/
},
paths: {
watched: ["static", "css", "js", "vendor", "../lib/my_app/web/elm"],
public: "../priv/static"
},
plugins: {
babel: {
ignore: [/vendor/]
},
elmBrunch: {
elmFolder: "../lib/my_app/web/elm",
mainModules: ["Main.elm"],
makeParameters: ['--debug'],
outputFolder: "assets/js"
}
},
modules: {
autoRequire: {
"js/app.js": ["js/app"]
}
},
npm: {
enabled: true
}
};
My app.js
file:
import "phoenix_html"
import Elm from "./main.js"
const elmDiv = document.getElementById('elm-main')
, elmApp = Elm.SeatSaver.embed(elmDiv)
But I get the error
iex(1)> 16:22:00 - error: Processing of js/app.js failed. Error: Could not load module ‘./main.js’ from ‘/home/ubuntu/workspace/my_app/assets/js’. Make sure the file actually exists.
Edit
Also tried with @Most instructions:
exports.config = {
files: {
javascripts: {
joinTo: "js/app.js"
},
stylesheets: {
joinTo: "css/app.css"
},
templates: {
joinTo: "js/app.js"
}
},
conventions: {
assets: /^(static)/
},
paths: {
watched: ["static", "css", "js", "vendor", "../lib/my_app/web/elm"],
public: "../priv/static"
},
plugins: {
babel: {
ignore: [/vendor/]
},
elmBrunch: {
elmFolder: "../lib/my_app/web/elm",
mainModules: ["Main.elm"],
outputFolder: "../../../../assets/js",
outputFile: "elm.js",
makeParameters: ['--debug']
},
},
modules: {
autoRequire: {
"js/app.js": ["js/app"]
}
},
npm: {
enabled: true
}
};
Running $ find -name "elm.js"
doesn’t return any file for given name, so it’s not compiling the file.
I keep getting
iex(1)> 16:39:50 - error: Processing of js/app.js failed. Error: Could not load module ‘./elm.js’ from ‘/home/ubuntu/workspace/my_app/assets/js’. Make sure the file actually exists.
What am I missing here?