Webpack从文件中排除文件

时间:2017-11-22 06:27:21

标签: webpack webpack-2

我在webpack.config中有三个入口点:

entry: {
   entry1: './app',
   entry2: './app/sub1',
   entry3: './app',
}

我需要从./app/excluded/excluded_file.js中排除单个文件(位于entry3):

之类的东西(在webpack中不起作用):

entry: {
   entry1: './app',
   entry2: './app/sub1',
   entry3: ['./app', '!./app/excluded/excluded_file.js'],
}

或使用Webpack插件?

1 个答案:

答案 0 :(得分:1)

如果使用模拟文件是一个可行的选项,您可以使用path-override-webpack-plugin 覆盖不受欢迎的模块路径:

// webpack.config.js 
import PathOverridePlugin from 'path-override-webpack-plugin';

const webpackConfig = {
    plugins: [
        // Adjust the paths to the structure of your project
        new PathOverridePlugin(/^app\/excluded/, './mock-folder')
    ]
}