Hi, I try to use Elm with Phoenix .
In files I have
package.json :
"dependencies": {
"elm": "^0.19.1-3",
"elm-webpack-loader": "^6.0.1",
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html"
},
in webpack.config.js
{
test: /\.elm$/,
exclude: [/elm-stuff/, /node_modules/],
use: {
loader: 'elm-webpack-loader',
options: {
cwd: path.resolve(__dirname, 'elm')
}
}
}
in js/app.js
import { ELm } from "../elm/src/Main.elm";
Elm.Main.init({
node: document.getElementById('elm-main')
})
Elm file (in asset/elm/src/Main.elm) :
module Main exposing (main)
import Html exposing (text)
main =
text "Hello Elm and Phoenix!"
and in index.html.eex
<div id="elm-main"></div>
All is compiled well ,
[./elm/src/Main.elm] 86.6 KiB {./js/app.js} [built]
[./js/app.js] 611 bytes {./js/app.js} [built]
[0] multi ./js/app.js 28 bytes {./js/app.js} [built]
+ 2 hidden modules
but I’ve got error in JS console on website:
Elm.Main.init({
node: document.getElementById('elm-main')
})
Uncaught ReferenceError: Elm is not defined
so ELM is not working. I have no idea where the problem is . Thanks in advance for help.