brunch.io conventionss.ignored不尊重node_modules

时间:2017-04-16 14:39:38

标签: brunch

我正在构建一个具有多个入口点的应用。它是一个插件/侧载反应架构。

我有一个基础反应应用程序编译到app.js和vendor.js就好了。该问题源于辅助项目,即主题,与一些相同的依赖项捆绑在一起。最值得注意的是反应和反应。我希望能够使用conventions.ignored来指示早午餐忽略特定的node_modules及其依赖项。无论我在convention.ignored中使用正则表达式,我仍然会在theme_vendor.js包中做出反应和反应。请参阅下面的配置:

const {theme_name} = require('./package.json');
module.exports = {
    sourceMaps: 'inline',
    files: {
        javascripts: {
            joinTo: {
                "theme.js": [
                    /^theme/,
                ],
                "theme_vendor.js": [
                    /^(?!theme)/,
                ],
            }
        },
        stylesheets: {
            joinTo: {
                'theme.css': ["theme/config/styles/index.scss"],
                'theme_ie11.css': ["theme/config/styles/ie.scss"],
            }
        }
    },
    conventions: {
        ignored: [
            /\/_/,
            "node_modules\/react",
            "node_modules\/react-dom",
        ],
    },
    plugins: {
        babel: {
            presets: ['es2015', 'stage-0', 'react'],
            plugins: [
                ['transform-runtime', {
                    polyfill: false,
                    regenerator: true
                }]
            ],
        },
        sass: {
            options: {
                includePaths: [],
                precision: 15
            },
            mode: 'native',
            sourceMapEmbed: true,
            debug: 'comments'
        },
        copycat: {
            "fonts/slick-carousel": ["node_modules/slick-carousel/slick/fonts"],
            "img/slick-carousel": ["node_modules/slick-carousel/slick/ajax-loader.gif"],
            "": ["theme/theme_header.tmpl", "theme/theme_body.tmpl", "theme/theme_footer.tmpl"],
        }
    },
    modules: {
        nameCleaner: path => path.replace('', theme_name + '/')
    },
    notifications: false,
    hot: false,
    paths: {
        public: '../',
        watched: [
            'theme',
            'initialize.js',
        ]
    },
    overrides: {
        production: {
            optimize: true,
            sourceMaps: false,
            plugins: {
                autoReload: {
                    enabled: false
                }
            },
            paths: {
                // public: "dist/"
            }
        }
    }
};

我能够实现任何接近的唯一方法是在joinTo中使用否定。见下文:

javascripts: {
            joinTo: {
                "theme.js": [
                    /^theme/,
                ],
                "theme_vendor.js": [
                    /^(?!theme|node_modules\/react|node_modules\/react-dom)/,
                ],
            }
        },

先谢谢您的帮助。 其他信息:

"dependencies": {
    "react-click-outside": "^2.2.0",
    "react-image-gallery": "^0.7.15",
    "react-slick": "^0.14.7",
    "slick-carousel": "^1.6.0"
  },
  "devDependencies": {
    "auto-reload-brunch": "^2",
    "babel-brunch": "~6.0.0",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-es2015": "^6.24.0",
    "babel-preset-react": "~6.22",
    "babel-preset-stage-0": "^6.22.0",
    "brunch": "^2",
    "clean-css-brunch": "^2",
    "copycat-brunch": "^1.1.0",
    "hmr-brunch": "^0.1",
    "redux-devtools": "^3.3.2",
    "redux-devtools-dock-monitor": "^1.1.1",
    "redux-devtools-log-monitor": "^1.2.0",
    "sass-brunch": "^2.10.4",
    "uglify-js-brunch": "^2",
    "isomorphic-fetch": "^2.2.1",
    "react": "^15.4",
    "react-addons-css-transition-group": "^15.4.2",
    "react-dom": "^15.4",
    "react-redux": "~4.3.0",
    "react-router": "^3.0.2",
    "react-router-redux": "^4.0.8",
    "redux": "~3.2.1",
    "redux-form": "^6.6.2",
    "redux-logger": "^3.0.0",
    "redux-saga": "^0.14.3"
  }

1 个答案:

答案 0 :(得分:1)

我认为你需要这样做:

conventions: {
  vendor: /(^bower_components|node_modules(?!\/react)|vendor)\//
}

另请参阅docs

编辑:我改变了答案。此正则表达式将与两个反应节点模块不匹配,因此不会包含在您的文件中。