我将webpack
与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'
}
}
提前谢谢。