首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >brunch.io conventions.ignored不尊重node_modules

brunch.io conventions.ignored不尊重node_modules
EN

Stack Overflow用户
提问于 2017-04-16 14:39:37
回答 1查看 258关注 0票数 1

我正在构建一个有多个入口点的应用程序。这是一个插件/副业反应体系结构。

我有一个基本的react应用程序,编译成app.js和vendor.js都很好。这个问题源于次要项目,即主题,它与一些相同的依赖关系捆绑在一起。最值得注意的是反应和反应.我希望能够使用conventions.ignored来指示早午餐忽略特定的node_modules及其依赖关系。不管我在conventions.ignored中放了什么正则表达式,我仍然会在theme_vendor.js包中得到。请参见下面的配置:

代码语言:javascript
复制
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中使用否定。见下文:

代码语言:javascript
复制
javascripts: {
            joinTo: {
                "theme.js": [
                    /^theme/,
                ],
                "theme_vendor.js": [
                    /^(?!theme|node_modules\/react|node_modules\/react-dom)/,
                ],
            }
        },

其他信息:

代码语言:javascript
复制
"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"
  }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-17 14:08:00

我觉得你应该这么做

代码语言:javascript
复制
conventions: {
  vendor: /(^bower_components|node_modules(?!\/react)|vendor)\//
}

也见文档

此regex将不匹配两个react节点模块,因此不会包含在您的文件中。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43438375

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档