- HTML中文网
- 联系QQ:88526
- QQ交流群
- 微信公众号
像javascript一样加载 CoffeeScript 。
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' ] } ] } }
Name | Default | Description |
---|---|---|
literate | false | Enable CoffeeScript in Markdown (Code Blocks) e.g file.coffee.md |
sourceMap | false | Enable/Disable Sourcemaps |
transpile | false | 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'] } } } ] } ] } }
推荐手册