1484226097 by Unknown

1484226097 by Unknown

Author:Unknown
Language: eng
Format: epub
Published: 2018-08-16T14:08:57+00:00


Chapter 4 tooling and libraries

Building

When we develop an Elm application we want to automate as much as possible, as follows:

• Compile changed files automatically.

• Build distribution files.

• Invoke tools easily.

• Run a web server with the compiled files.

• Support JavaScript frameworks and CSS creation.

Luckily, we can use the same tools the JavaScript web community has created. Apart from Webpack2 mentioned in the previous section, we also have Gulp3 and Grunt4 available.

All the previously mentioned tools require configurations and use many other Node packages to do their jobs. If you just want to watch Elm files and compile them when they have changed, a more lightweight solution would be Chokidar5 or Chokidar-cli.6 The following script (Listing 4-11) can be integrated into the scripts section in package.json.

Listing 4-11.

"watch": "chokidar '**/*.elm' -c 'elm make allbasics.elm

--output elm.js --warn' --initial"

Whenever a file changes, the main file allbasics.elm and dependent files will be compiled with the --warn option. The tool has many more options and is used by other build tools, like the aforementioned Gulp or Webpack.

This is not the place to go much deeper into the configuration of the different build tools, which would almost require a small book of its own. A development team will use what they are comfortable with. Build tools working together with scaffolding and editor plugins are the key to successfully implementing Elm applications that are bigger than a simple Hello World.

2 https://webpack.github.io/

3 https://www.npmjs.com/package/gulp-elm

4 https://www.npmjs.com/package/grunt-elm

5 https://github.com/paulmillr/chokidar

6 https://github.com/kimmobrunfeldt/chokidar-cli

93



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.