如何避免webpack将所有文件捆绑在一起?

时间:2018-02-22 13:41:57

标签: javascript node.js webpack serverless-framework serverless-webpack-plugin

我将webpackserverless 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'
  }
}

提前谢谢。

0 个答案:

没有答案