1
前言
我目前的开关我们构建过程在从Browserify到的WebPack。由于该项目使用咖啡脚本了很多,我有很多import语句,如:使用的WebPack的咖啡装载机但没有明确指出“.coffee”文件扩展名
require('./coffee-file-without-extension') # note the lack of .coffee
require('./legacy-js-file-without-extension') # note the lack of .js
问题
Browserify处理没有文件扩展名就好了。的WebPack似乎已经按照该错误问题:
Module not found: Error: Can't resolve './wptest-req' in '/Users/jusopi/Dev/Workspaces/nx/nx-ui/src'
我建立一个超级简单的测试项目为这个,我有以下文件:
wptest.coffee
require('./wptest-req')
wptest -req.coffee
module.exports = {}
webpack.config.js
const path = require('path');
const webpack = require('webpack')
module.exports = {
entry: {
main: './src/wptest.coffee'
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist')
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'common' // Specify the common bundle's name.
})
],
module: {
rules: [
{
test: /\.coffee$/,
use: [
{
loader: 'coffee-loader',
options: { sourceMap: true }
}
]
}
]
}
};
最终目标
我希望我没有走过去每文件在我们的应用程序和附加.coffee
所有如果可能的话,要求提供咖啡文件的声明。