Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

可配置额外需要做 babel 转换处理的文件规则 #40

Closed
sorrycc opened this issue Dec 30, 2016 · 17 comments
Closed

可配置额外需要做 babel 转换处理的文件规则 #40

sorrycc opened this issue Dec 30, 2016 · 17 comments
Milestone

Comments

@sorrycc
Copy link
Owner

sorrycc commented Dec 30, 2016

ant-design/ant-design#4418, #35

@sorrycc sorrycc changed the title 配置额外需要做 babel 转换处理的文件 可配置额外需要做 babel 转换处理的文件规则 Dec 30, 2016
@szwork2013
Copy link

如果没有 webpack.config.js配置文件,动态加载route还不能对 chunkFilename配置吗?比如 '[name].[hash].js'

@sorrycc
Copy link
Owner Author

sorrycc commented Jan 10, 2017

动态加载的文件为何要进行命名?

@szwork2013
Copy link

我是说按需加载方式生成在dist的文件,加上 [hash]后可以自动部署在生产环境,不用手工加其他防止缓存的参数

@gzbigegg
Copy link

gzbigegg commented Feb 4, 2017

这个现在有了吗?我在 .roadhog.mock.js 中引入了 mockjs,估计要这个才能修复。

@sorrycc
Copy link
Owner Author

sorrycc commented Feb 5, 2017

这个现在有了吗?我在 .roadhog.mock.js 中引入了 mockjs,估计要这个才能修复。

这个和 babel 转换无关吧。

@gzbigegg
Copy link

gzbigegg commented Feb 5, 2017

好象之前看你写到过 babel 默认只对 ./src 目录下的文件做处理。我在 .roadhog.mock.js 文件中包含了其他的带有 mockjs 数据的文件,因为 .roadhog.mock.js 不在 ./src 目录下,所以这一系列的文件都必须用老的 JS 的语法。目前来看问题不是很大,能绕过去,比较困扰的是有一个浏览器的 localStorage 不能直接用了。

@sorrycc
Copy link
Owner Author

sorrycc commented Feb 5, 2017

./.roadhogrc.mock.js./mock/ 文件夹都是走 babel 解析的。

@gzbigegg
Copy link

gzbigegg commented Feb 5, 2017

等你下一个版本发布了我再试试吧。

@sorrycc
Copy link
Owner Author

sorrycc commented Mar 29, 2017

roadhog 实现:

  1. 通过 .roadhogrc 的 extraBabelIncludes 规则,指定除 src 目录外需要 babel 处理的文件夹
  2. 一条文件夹加一个 babel loader 处理规则
{
  test: /\.(js|jsx)$/,
  include: %文件夹%,
  loader: 'babel',
},

@sorrycc sorrycc added this to the 0.6 milestone May 5, 2017
@zhengqingxin
Copy link

@sorrycc 一条文件夹加一个 babel loader 处理规则这里还是没太懂,要在哪里加呢?

@sorrycc
Copy link
Owner Author

sorrycc commented Aug 29, 2017

这是内部实现,不用管。参考这个用例进行配置吧,https://github.com/sorrycc/roadhog/blob/master/test/fixtures/build/extraBabelIncludes/.roadhogrc

@zhengqingxin
Copy link

zhengqingxin commented Aug 29, 2017

我用dva新建了一个项目,修改目录结构为:

然后将.roadhogrc改为一下内容:

{
  "entry": "src/index.js",
   "extraBabelIncludes": [
      "www/static/src"
    ],
  "env": {
    "development": {
      "extraBabelPlugins": [
        "dva-hmr",
        "transform-runtime"
      ]
    },
    "production": {
      "extraBabelPlugins": [
        "transform-runtime"
      ]
    }
  }
}

发现将 index.js 和 index.css 编译成了 html 的内容?如图:

dva-cli 版本 0.7.8,roadhog 版本 0.5.4

@sorrycc
Copy link
Owner Author

sorrycc commented Aug 29, 2017

entry 没配对。

@zhengqingxin
Copy link

entry 要配成 www/static/src 吗? 这样配会报 Unexpected token 那个错误了

@sorrycc
Copy link
Owner Author

sorrycc commented Aug 29, 2017

roadhog 升级下,0.5.4 估计还没这个配置项。

@baobao12356
Copy link

"extraBabelIncludes": [
	"node_modules/qs",
	"node_modules/query-string",
	"node_modules/events",
	"node_modules/dashjs",
	"node_modules/pearplayer",
	"node_modules/webtorrent",
	"node_modules/dplayer",
	"node_modules/shaka-player",
	"node_modules/hls.js",
	"node_modules/flv.js",
	"node_modules/typescript",
	"node_modules/event-emitter",
	"node_modules/dva-immer",
	"node_modules/immer"
]这样么?

@baobao12356
Copy link

这是内部实现,不用管。参考这个用例进行配置吧,https://github.com/sorrycc/roadhog/blob/master/test/fixtures/build/extraBabelIncludes/.roadhogrc

这打开是404
Uploading image.png…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants