我写了这个webpack加载器
module.exports = function(source) {
return `export default 'hello'`;
}
我要使用es6导入重写的
export default function loader(source) {
return `export default 'hello'`;
}
没有成功
SyntaxError:意外的令牌导出
我的webpack配置为:
const path = require('path')
module.exports = {
mode: 'development',
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},,
resolveLoader: {
modules: [
'node_modules',
path.resolve(__dirname, 'loaders')
]
},
module: {
rules: [{
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}, {
test: /\.txt$/,
use: {
loader: 'my-loader'
}
}]
}
};
我该怎么做?