Skip to content
vic

vic/elmx-webpack-preloader

Compile elmx to elm files before using elm-webpack-loader

vic/elmx-webpack-preloader.json
{
"defaultBranch": "master",
"description": "Compile elmx to elm files before using elm-webpack-loader",
"fullName": "vic/elmx-webpack-preloader",
"homepage": "https://www.npmjs.com/package/elmx-webpack-preloader",
"language": "JavaScript",
"name": "elmx-webpack-preloader",
"pushedAt": "2018-04-19T07:13:27Z",
"stargazersCount": 2,
"updatedAt": "2018-04-19T07:09:10Z",
"url": "https://github.com/vic/elmx-webpack-preloader"
}

help maintain this lib

Compile elmx to elm files before using elm-webpack-loader

Example App

Terminal window
npm install --save-dev elmx-webpack-preloader

Add the preload to your webpack config. Any .elmx dependency will be compiled to an .elm file.

If no outputDirectory is specified, the compiled elm will be placed in the same directory as it’s elmx source.

{
module: {
preLoaders: [
{
// Notice that the preloader actually reads .elm files looking for dependencies to be compiled from elmx
test: /\.elm$/,
loader: 'elmx-webpack-preloader',
include: [join(__dirname, "src/elm")],
query: {
sourceDirectories: ['src/elm']
outputDirectory: '.tmp/elm'
}
}
],
loaders: [
{
test: /\.elm$/,
loader: 'elm-webpack',
include: [join(__dirname, "src/elm"), join(__dirname, ".tmp/elm")]
}
]
}
}

When using an outputDirectory make sure to include it on your elm-package.json

{
"source-directories": [
"src/elm",
".tmp/elm"
]
}