从 Webpack 转换中排除特定的 JS 文件,但包含在包中

Exclude specific JS file from Webpack transpilation, but include in bundle

我有一个非常大的 JS 文件 pleaseExcludeMe.js,它已经缩小并转译包含在我的 vue 项目中,它使用默认的 webpack 设置。

我想从 Webpack 中排除该文件 transpilation/transformation,但显然在捆绑包中需要它

该文件由 Rooms.vue 导入。

这是我的项目结构:

root
  src/
    views/
      rooms/
        Rooms.vue
        pleaseExcludeMe.js  
  package.json

在我的 vue.config.js 中,我已经尝试过这个:

configureWebpack: {
    module: {
        rules: [
            {
                test: /pleaseExcludeMe/,
                loader: 'null-loader', // also tried 'dumb-loader'
                exclude: /pleaseExcludeMe/, // this seems to exclude the file from the bundle
            },
        ],
    },
},

如何排除该特定文件?

我想通了:

const path = require('path');

// ...
rules: [
  test: /\.js$/,
  exclude: [
    path.resolve(__dirname, 'src/views/rooms/pleaseExcludeMe.js'),
  ],
]