Hello,
my project is structured:
~/myproj
|- node_modules
|- lib
|- shared.js
|- service1
| - serverless.yml
| - webpack.config.js
| - service1.js <-- import Something from '../lib/shared';
webpack.config.js:
const path = require('path');
const slsw = require('serverless-webpack');
const nodeExternals = require('webpack-node-externals');
module.exports = {
entry: slsw.lib.entries,
target: 'node',
externals: [nodeExternals({modulesDir:'../node_modules'})],
module: {
loaders: [{
test: /\.js$/,
loaders: ['babel-loader'],
include: __dirname,
exclude: /node_modules/,
}]
},
output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, '.webpack'),
filename: '[name].js'
}
};
The file in lib/shared.js is not being Babel compiled and the build is failing because of ES6 syntax (if I move to the ./service1 dir everything is fine)
Thanks