小编Ser*_*gey的帖子

包含/排除不起作用

网络包 2.2.0

我在我的配置中包含/排除文件/文件夹,但 webpack 一直捆绑被排除的:

文件夹结构

src/
  index.js // entry point
server/
  test.js // file for testing
build/
Run Code Online (Sandbox Code Playgroud)

webpack.config.js

const path = require('path')
const SRC = path.resolve(process.cwd(), './src')
const BUILD = path.resolve(process.cwd(), './build')

module.exports = {
  context: SRC,
  entry: {
    main: './'
  },
  output: {
    path: BUILD,
    filename: '[name].bundle.js',
    publicPath: '/assets/'
  },
  module: {
    rules: [{
      test: /\.jsx?/,
      include: SRC,
      exclude: path.resolve(process.cwd(), './server’), // even explicit excluding changes nothing
      loader: 'babel-loader'
    }]
  }
}
Run Code Online (Sandbox Code Playgroud)

./src/index.js

import func from ‘../server/test.js’ // …
Run Code Online (Sandbox Code Playgroud)

webpack

5
推荐指数
1
解决办法
3708
查看次数

标签 统计

webpack ×1