Use elm binary selectively
- node_modules
- global
- give through config
Would this be an additional config option possibly to be able to pass in pathToElm directly node-elm-compiler? If so I'd be happy to make a PR. I know I'll be wanting to use https://github.com/mdgriffith/elm-optimize-level-2 soon-ish for my project.
Definitely that was what I intended for 3 but wondering some fancy ways to pick elm binary.
Like if a project which uses this package has elm via npm should pick that automatically and just use elm (env global) for otherwise. config.pathToElm can overwrite them forcibly.
Feel free to submit a PR to enable pathToElm config (then pass down into node-el-compiler. Thanks!
Cool, I'm testing this out locally for a bit to make sure I'm not breaking anything. I'll make a PR once I feel it's working well.
@wolfadex I’m evaluating Vite as a build framework. Could you find a way to use elm-optimize-level-2 for production builds?
I did but need to refactor my approach and have been distracted by non-code things recently.
After my initial attempt, elm-optimize-level-2 made a change to allow running with a make command which should allow it to be used with node-elm-compiler.
I'm just considering managing compilers within this plugin then get rid of node-elm-compiler since this plugin is not fully using their features. We should be able to spawn a compiler by ourselves. In the same time, I expect to accept elm-optimize-level-2 could be easier. Only the concern is HMR stuff and asset handlings should be rewritten for elm-optimize-level-2 (have you looked around?).
Anyways, will be back after #217 is closed.
Any news regarding this? 😄 As I already include different dependencies in my index.js, I like to also include Elm as a dependency. It also makes it easier for other developers who is new to Elm to get right into development instead of setup.
Thus, it would be great for me to be able to specify pathToElm as a config!
Now that v2.9.0-beta.1 accepts raw options for node-elm-compiler via nodeElmCompilerOptions it is finally possible to use elm-optimize-level-2! :tada:
elmPlugin({
optimize: false, // no `--optimize` option when using elm-optimize-level-2
nodeElmCompilerOptions: {
pathToElm: process.env.NODE_ENV === 'production' ? 'node_modules/elm-optimize-level-2/bin/elm-optimize-level-2' : undefined
}
})
You may get depreciation warnings as described in https://github.com/mdgriffith/elm-optimize-level-2/issues/104.