赞助 webpack,同时从官方商店购买衣服 或者在这里购买贴纸!所有收益将转到我们的 open collective

coffee-loader

Loads CoffeeScript like JavaScript

安装

npm install --save-dev coffee-loader

用法

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

##

import coffee from 'file.coffee';

webpack.config.js

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

Options

Name
Default
Description
Name
literate
Default
false
Description
Enable CoffeeScript in Markdown (Code Blocks) e.g file.coffee.md
Name
sourceMap
Default
false
Description
Enable/Disable Sourcemaps
Name
transpile
Default
false
Description
Provide Babel presets and plugins

Literate

webpack.config.js

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

Sourcemaps

webpack.config.js

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

Transpile

webpack.config.js

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

Maintainer


Juho Vepsäläinen


Joshua Wiens


Kees Kluskens


Sean Larkin