我正在使用webpack
with serverless framework
,我想知道是否可以避免捆绑所有文件。
这是我的结构:
services/
|- checkups/
||
|| some_file.js
utils/
|- other_file.js
在some_file
,我正在导入other_file
:
// some_file.js
import otherFile from '../../utils/other_file/
当我运行运行 webpack 的部署时,所有文件都只转入一个:handle.js
,当我需要它们分开时。那可能吗?
我目前webpack.config
是:
const path = require('path')
const slsw = require('serverless-webpack')
const nodeExternals = require('webpack-node-externals')
module.exports = {
entry: slsw.lib.entries,
target: 'node',
devtool: 'source-map',
node: {
__dirname: false
},
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'
}
}
先感谢您。