I wrote this webpack loader
module.exports = function(source) {
return `export default 'hello'`;
}
that I want to rewrite using es6 imports
export default function loader(source) {
return `export default 'hello'`;
}
without success
SyntaxError: Unexpected token export
My webpack configuration is:
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'
}
}]
}
};
How can I do this?