'import' and 'export' may only appear at the top level
'import' and 'export' may only appear at the top level
This means that webpack is bundling the non-transpiled ES6 code, which is why these import
/export
statements are being found. babel-loader
must therefore not be transpiling what you expect.
If you simply remove the include
and exclude
rules from its loader config, the default behavior of transpiling everything besides what's in node_modules
will kick in. For some reason or another, the current rules are causing some/all files to be skipped.
module.exports = {
entry: './src/entry.js',
output: {
filename: './public/js/app.js'
},
devtool: 'source-map',
plugins: [
new ExtractTextPlugin('./public/css/style.css')
],
module: {
preLoaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'jshint-loader'
}],
loaders: [{
test: /\.scss$/,
loader: ExtractTextPlugin.extract(
'style',
'css!sass'
),
},
{
test: /\.vue$/,
loader: 'vue'
},
{
test: /\.js$/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
}]
}
};
I got this error when I was missing a closing bracket.
Simplified recreation:
const foo = () => {
return (
'bar'
);
}; <== this bracket was missing
export default foo;