Coder Social home page Coder Social logo

vic / elmx-webpack-preloader Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 2.0 14 KB

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

Home Page: https://www.npmjs.com/package/elmx-webpack-preloader

License: BSD 3-Clause "New" or "Revised" License

JavaScript 100.00%
elmx elm webpack-plugin webpack-loader

elmx-webpack-preloader's Introduction

elmx-webpack-preloader

help maintain this lib

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

Example App

Installation

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

Usage

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"
    ]
}

elmx-webpack-preloader's People

Contributors

vic avatar lermex avatar

Stargazers

Jakub Zawiślak avatar yetone avatar

Watchers

James Cloos avatar  avatar

elmx-webpack-preloader's Issues

Entry point file Main.elm can't be elmx

I'm new to webpack and I've set up a simple project for myself that uses elmx. However, having reviewed the code of this library and trying a bunch of different configurations, it seems like the initial entry Elm file is expected to be .elm, like Main.elm instead of Main.elmx. Is that a limitation of the current implementation of this library, or is it an issue with my setup?

Issue with Elm 0.17?

I'm not sure if this is Elm 0.17 issue, but might be:

/home/ielectric/dev/hydra-frontend/node_modules/elmx-webpack-preloader/node_modules/elmx/dist/generator.js:83
  var expr = state.expr;
                  ^

TypeError: Cannot read property 'expr' of undefined
    at generate (/home/ielectric/dev/hydra-frontend/node_modules/elmx-webpack-preloader/node_modules/elmx/dist/generator.js:83:19)
    at module.exports (/home/ielectric/dev/hydra-frontend/node_modules/elmx-webpack-preloader/node_modules/elmx/dist/parser.js:38:10)
    at /home/ielectric/dev/hydra-frontend/node_modules/elmx-webpack-preloader/index.js:137:34
    at /home/ielectric/dev/hydra-frontend/node_modules/elmx-webpack-preloader/node_modules/mkdirp/index.js:48:26
    at FSReqWrap.oncomplete (fs.js:82:15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.