Giter Site home page Giter Site logo

andys8 / elm-asset-webpack-loader Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 3.0 109 KB

Webpack loader for assets (like images or fonts) in Elm programming language

Home Page: https://www.npmjs.com/package/elm-asset-webpack-loader

License: MIT License

JavaScript 100.00%
webpack elm elm-lang image loader

elm-asset-webpack-loader's Introduction

elm-asset-webpack-loader

Webpack loader for assets (like images or fonts) in Elm programming language

Usage

img [ src "require:src/assets/logo.svg" ] []

Webpack

  • This loader is meant to be run in combination with elm-webpack-loader
  • The configuration isn't allowed to have noParse for elm files
{
  test: /\.elm$/,
  use: [
    {
      loader: require.resolve("elm-asset-webpack-loader")
    },
    {
      loader: require.resolve("elm-webpack-loader")
    }
  ]
}

With this configuration other loaders (like this svg example) can be used:

{
  test: /\.svg$/,
  loader: require.resolve("file-loader"),
  options: {
    name: "static/media/[name].[hash:8].[ext]"
  }
}

Goals

Path safety

The build should fail at compile time if an asset path is used, that isn't existing or misspelled.

Webpack loaders

With this approach any webpack loader can be used. Use cases can be to hash file names, to optimize images and more. See awesome-webpack#loaders.

Prior art and alternatives

  • elm-assets-loader is a comparable approach, and is more sophisticated. The package is marked as deprecated.
  • babel-elm-assets-plugin is using babel. It mentions to disable Elm optimization. This could be because it's using a String type alias.
  • It's possible to require files in JavaScript and pass them as flags to Elm (Instructions)

Release

elm-asset-webpack-loader's People

Contributors

andys8 avatar birowsky avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

elm-asset-webpack-loader's Issues

Impact of removing `noParse`

It's necessary to remove noParse for elm files (like similar approaches). Otherwise webpack couldn't find the require keywords. The impact on performance might be interesting.

module.noParse takes a regex or a function as argument. A function might help to specify or exclude files/folders.

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.