All Projects → webpack-contrib → Coffee Loader

webpack-contrib / Coffee Loader

Licence: mit
CoffeeScript Loader

Programming Languages

javascript
184084 projects - #8 most used programming language
coffeescript
4710 projects

Projects that are alternatives of or similar to Coffee Loader

Svg Fill Loader
DEPRECATED, use https://github.com/kisenka/svg-mixer/tree/master/packages/svg-transform-loader instead
Stars: ✭ 74 (-44.78%)
Mutual labels:  webpack-loader
Css Modules Flow Types
Creates flow type definitions from CSS Modules files using Webpack loader or CLI 👾
Stars: ✭ 92 (-31.34%)
Mutual labels:  webpack-loader
Webpack Tools
☕️Just a simple webpack sample project.
Stars: ✭ 106 (-20.9%)
Mutual labels:  webpack-loader
Vue Md Loader
✨ Markdown files to ALIVE Vue components.
Stars: ✭ 78 (-41.79%)
Mutual labels:  webpack-loader
Ignore Loader
Webpack loader to ignore certain package on build.
Stars: ✭ 85 (-36.57%)
Mutual labels:  webpack-loader
Webpack Core Usage
webpack2完整系列课程,欢迎阅读。同时欢迎移步我的react全家桶文章全集: https://github.com/liangklfangl/react-article-bucket
Stars: ✭ 94 (-29.85%)
Mutual labels:  webpack-loader
Svg Sprite Webpack Plugin
Webpack plugin for loading/extracting SVGs into a sprite file
Stars: ✭ 73 (-45.52%)
Mutual labels:  webpack-loader
Transform Loader
transform loader for webpack
Stars: ✭ 116 (-13.43%)
Mutual labels:  webpack-loader
Worker Loader
A webpack loader that registers a script as a Web Worker
Stars: ✭ 1,284 (+858.21%)
Mutual labels:  webpack-loader
Webpack Component Loader
📦 A webpack loader to componentify CSS/JS/HTML without framework
Stars: ✭ 105 (-21.64%)
Mutual labels:  webpack-loader
Sprite Loader
A image sprite loader for webpack.
Stars: ✭ 82 (-38.81%)
Mutual labels:  webpack-loader
Graphql Import Loader
Webpack loader for `graphql-import`
Stars: ✭ 84 (-37.31%)
Mutual labels:  webpack-loader
Url Loader
A loader for webpack which transforms files into base64 URIs
Stars: ✭ 1,361 (+915.67%)
Mutual labels:  webpack-loader
Node Loader
node loader for native modules
Stars: ✭ 77 (-42.54%)
Mutual labels:  webpack-loader
Vue Theme Loader
A webpack loader for supporting multi-site theming with Vue.js
Stars: ✭ 109 (-18.66%)
Mutual labels:  webpack-loader
Graphql Persisted Document Loader
Webpack loader that adds a documentId to a compiled graphql document, which can be used when persisting/retrieving documents
Stars: ✭ 74 (-44.78%)
Mutual labels:  webpack-loader
Webpack Conditional Loader
C conditionals directive for JavaScript
Stars: ✭ 93 (-30.6%)
Mutual labels:  webpack-loader
Style Loader
Style Loader
Stars: ✭ 1,572 (+1073.13%)
Mutual labels:  webpack-loader
Sass Vars Loader
Use Sass variables defined in Webpack config or in external Javascript or JSON files
Stars: ✭ 112 (-16.42%)
Mutual labels:  webpack-loader
Vue Svg Inline Loader
Webpack loader used for inline replacement of SVG images with actual content of SVG files in Vue projects.
Stars: ✭ 105 (-21.64%)
Mutual labels:  webpack-loader

npm node deps tests coverage chat size

coffee-loader

Compile CoffeeScript to JavaScript.

Getting Started

To begin, you'll need to install coffeescript and coffee-loader:

npm install --save-dev coffeescript coffee-loader

Then add the plugin to your webpack config. For example:

file.coffee

# Assignment:
number   = 42
opposite = true

# Conditions:
number = -42 if opposite

# Functions:
square = (x) -> x * x

# Arrays:
list = [1, 2, 3, 4, 5]

# Objects:
math =
  root:   Math.sqrt
  square: square
  cube:   (x) -> x * square x

# Splats:
race = (winner, runners...) ->
  print winner, runners

# Existence:
alert "I knew it!" if elvis?

# Array comprehensions:
cubes = (math.cube num for num in list)

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.coffee$/,
        loader: 'coffee-loader',
      },
    ],
  },
};

Alternative usage:

import coffee from 'coffee-loader!./file.coffee';

And run webpack via your preferred method.

Options

Type: Object Default: { bare: true }

Options for CoffeeScript. All possible options you can find here.

Documentation for the transpile option you can find here.

ℹ️ The sourceMap option takes a value from the compiler.devtool value by default.

ℹ️ The filename option takes a value from webpack loader API. The option value will be ignored.

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.coffee$/,
        loader: 'coffee-loader',
        options: {
          bare: false,
          transpile: {
            presets: ['@babel/env'],
          },
        },
      },
    ],
  },
};

Examples

CoffeeScript and Babel

From CoffeeScript 2 documentation:

CoffeeScript 2 generates JavaScript that uses the latest, modern syntax. The runtime or browsers where you want your code to run might not support all of that syntax. In that case, we want to convert modern JavaScript into older JavaScript that will run in older versions of Node or older browsers; for example, { a } = obj into a = obj.a. This is done via transpilers like Babel, Bublé or Traceur Compiler.

You'll need to install @babel/core and @babel/preset-env and then create a configuration file:

npm install --save-dev @babel/core @babel/preset-env
echo '{ "presets": ["@babel/env"] }' > .babelrc

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.coffee$/,
        loader: 'coffee-loader',
        options: {
          transpile: {
            presets: ['@babel/env'],
          },
        },
      },
    ],
  },
};

Literate CoffeeScript

For using Literate CoffeeScript you should setup:

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.coffee$/,
        loader: 'coffee-loader',
        options: {
          literate: true,
        },
      },
    ],
  },
};

Contributing

Please take a moment to read our contributing guidelines if you haven't yet done so.

CONTRIBUTING

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].