gajus / gajus/babel-plugin-react-css-modules

Does it work with Browserify?

未关闭
#263 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
question
主要语言
JavaScript
星标
2k
派生
159
PR 合并指标
30 天内没有已合并 PR

描述

Does this plugin work with babelify? (browserify plugin for babel)

I've been trying to make it work but no luck, here is my Gulp task:

```js
gulp.task('react', function() {
const b = browserify({
entries: path.join(webContentDir, 'app/index.js'),
extensions: ['.js', '.jsx'],
debug: true,
transform: [
babelify.configure({
presets: [
'@babel/preset-env',
'@babel/preset-react'
],
plugins: [
['@babel/transform-react-jsx', {'pragma': 'h'}],
['babel-plugin-react-css-modules']
]
})
]
});
return b.bundle()
.pipe(source(path.join(webContentDir, 'dist/bundle.js')))
.pipe(gulp.dest('.'));
});
```

When I import a CSS file it seems to not process it with this plugin at all (as if I don't include it):

```
.answer-input {
^
ParseError: Unexpected token
```

Any ideas why it's not working?

```
"@babel/core": "^7.4.5",
"@babel/plugin-transform-react-jsx": "^7.3.0",
"@babel/preset-env": "^7.4.5",
"@babel/preset-react": "^7.0.0",
"babel-plugin-react-css-modules": "^5.2.6",
"babelify": "^10.0.0",
"browserify": "^16.2.3",
```

贡献指南

这个仓库没有索引到贡献指南

调研方向

从所示的 Gulp 任务及其 Browserify babelify transform 配置开始,然后检查 CSS import 如何到达 babel-plugin-react-css-modules。使用列出的软件包版本重现 Unexpected token 错误,并验证导入的 CSS 会被处理,而不是作为 JavaScript 进行解析。

由索引模型根据 Issue 内容生成。

评估

技术栈
babel, css, javascript, react
领域
build-system, frontend
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。