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

roadhog 2.0 发布 #55

Open
sorrycc opened this Issue Jan 2, 2018 · 99 comments

Comments

Projects
None yet
@sorrycc
Owner

sorrycc commented Jan 2, 2018

趁着元旦,roadhog 2.0 发布了,我们一起来看看有啥变化吧。

👏 👏 👏
 

一、

首先,我们把底层重写,基于 af-webpack

为啥要基于 af-webpack?单看 roadhog,这意义不大,但如果有数个工具都基于 af-webpack 做上层封装,那么就意味着 webpack 工具层的配置统一。 尤其对我们内部来说,有 4-5 个工具,每个工具有各自的配置方法,对于开发者来说无疑是个灾难。对外部的同学来说,umi 和 roadhog 都基于 af-webpack,那么之后在这两个工具之间切换,webpack 的配置层是无需变动的。

另外,大家会发现 roadhog 的 issue 维护不太积极,是因为我的工作重心目前不在这,而是在 umi 上。所以切换到 af-webpack,af-webpack 是 umi 的底层共建,这样就可以变相地保证我在这个项目上的投入。

同时,为了更通用,配置文件从 .roadhogrc 更名为 .webpackrc

 

二、

然后,在体验上,保持了和 create-react-app 最新版一致。像是 redbox 显示出错信息、HMR、出错点击后跳转到 IDE、ESLint 出错提示等等。

并在此基础上,增加了:

  • 所有的配置都能自动生效(热更新或自重启)
  • dev server 断线重连
  • 配置项校验和提醒(同时出现在浏览器和控制台里)
  • 配置文件语法错误提示到行
  • ...

 

三、

roadhog 从命令的维度看,包含 dev (mock),build,test。

变化是:

  • 原 server 命令改名为 dev
  • dev 和 build 主要是配置上的变化
  • mock 保持不变
  • test 从 mocha 改为 jest,同时支持 UI 组件的测试

 

四、

配置项即功能,这里有比较大的变化。

不再支持的有:

  • multipage (use commons instead)
  • autoprefixer (use browserslist instead)
  • dllPlugin (学习成本太高,并且有其他方法可以提升 dev server 启动速度)
  • svgSpriteLoaderDirs
  • library
  • libraryTarget
  • cssModulesExclude

功能变化的有:

  • publicPath(dev 模式下的也可覆写了)
  • sass(值从 Boolean 改成 Object,内容为传给 node-sass 的配置项)

新的有:

  • babel
  • copy
  • commons
  • browserslist
  • alias (总算加上了,因为我发现 babel 插件代替不了 alias,因为 babel 不处理 node_modules)
  • devtool (可给生产环境开启 sourcemap 了)
  • extraResolveModules
  • manifest(生成 manifest.json)

 

五、

此外,还有一些变化:

  • 不再支持通过 src/index.ejs 的方式生成 Html

 

六、

最后,我们对照 ant-design-pro 的升级 PR 来看下如何升级到 raodhog@2 。

对于大部分的应用来说,只要:

  • 升级 roadhog 版本为 2.x
  • 更名 .roadhogrc 为 .webpackrc
  • 更名 roadhog server 为 roadhog dev

然后,由于内置了 babel@7

  • 如果你有用 babel-polyfill,更换为 @babel/polyfill
  • 如果有 babel-runtime 依赖和配置了 babel-plugin-transform-runtime 插件,需删除,因为已内置处理,否则可能会报 this.setDynamic is not a function 的错误
  • 由于 babel@7 无法使用 babel-plugin-add-module-exports,所有的 require('./file') 需改为 require('./file').default
  • 如果有用 babel-plugin-dva-hmr,请升级到 0.4.x,

再然后,如果有 src/index.ejs,需要额外配置 html 属性,

"html": { "template": "./src/index.ejs" }

最后,有些配置不再支持,需考虑替代方案或使用 webpack.config.js 进行配置。

 

(完)

@afc163

This comment has been minimized.

Show comment
Hide comment
@afc163

afc163 Jan 2, 2018

之前有用 src/index.ejs,需移到 public/index.html,并手动引入 CSS 和 JS

如果开启了 hash,这个 html 岂不是要手动维护。

afc163 commented Jan 2, 2018

之前有用 src/index.ejs,需移到 public/index.html,并手动引入 CSS 和 JS

如果开启了 hash,这个 html 岂不是要手动维护。

@sorrycc

This comment has been minimized.

Show comment
Hide comment
@sorrycc

sorrycc Jan 2, 2018

Owner

这个 public/index.html dev 用(dev 时不会开 hash 的),build 后通常不会用到静态的 html。之前的 html 生成没处理好,很多反馈,就先下掉了,后面后需求再加上。

Owner

sorrycc commented Jan 2, 2018

这个 public/index.html dev 用(dev 时不会开 hash 的),build 后通常不会用到静态的 html。之前的 html 生成没处理好,很多反馈,就先下掉了,后面后需求再加上。

@afc163

This comment has been minimized.

Show comment
Hide comment
@afc163

afc163 Jan 2, 2018

这样会让人误解的,public/index.html 引用的 index.js 在 dist 里根本不存在。

afc163 commented Jan 2, 2018

这样会让人误解的,public/index.html 引用的 index.js 在 dist 里根本不存在。

@sorrycc

This comment has been minimized.

Show comment
Hide comment
@sorrycc

sorrycc Jan 2, 2018

Owner

那开个 html 的配置项,然后透传给 html-webpack-plugin 吧。

e.g.

"html": {
  "template": "./src/index.ejs"
}
Owner

sorrycc commented Jan 2, 2018

那开个 html 的配置项,然后透传给 html-webpack-plugin 吧。

e.g.

"html": {
  "template": "./src/index.ejs"
}
@sorrycc

This comment has been minimized.

Show comment
Hide comment
@sorrycc
Owner

sorrycc commented Jan 2, 2018

@elivoa

This comment has been minimized.

Show comment
Hide comment
@elivoa

elivoa Jan 3, 2018

“出错点击后跳转到 IDE” 这个 IDE如何设置?

elivoa commented Jan 3, 2018

“出错点击后跳转到 IDE” 这个 IDE如何设置?

@sorrycc

This comment has been minimized.

Show comment
Hide comment
@sorrycc

sorrycc Jan 3, 2018

Owner

“出错点击后跳转到 IDE” 这个 IDE如何设置?

不用设置,自动判断的。

Owner

sorrycc commented Jan 3, 2018

“出错点击后跳转到 IDE” 这个 IDE如何设置?

不用设置,自动判断的。

@elivoa

This comment has been minimized.

Show comment
Hide comment
@elivoa

elivoa Jan 3, 2018

不用设置,自动判断的。

我点击后打开的是sublime text,但是我想让他用web storm打开。是和操作系统的设置有关?比如js文件的默认打开程序?但是我.js默认使用VSCode打开的。

elivoa commented Jan 3, 2018

不用设置,自动判断的。

我点击后打开的是sublime text,但是我想让他用web storm打开。是和操作系统的设置有关?比如js文件的默认打开程序?但是我.js默认使用VSCode打开的。

@sorrycc

This comment has been minimized.

Show comment
Hide comment
@sorrycc

sorrycc Jan 3, 2018

Owner

你把 sublime 关了,然后开着 webstorm,看下是用什么打开的。

Owner

sorrycc commented Jan 3, 2018

你把 sublime 关了,然后开着 webstorm,看下是用什么打开的。

@elivoa

This comment has been minimized.

Show comment
Hide comment
@elivoa

elivoa Jan 3, 2018

明白了,要设置REACT_EDITOR环境变量

Could not open search.js in the editor.
The editor process exited with an error: spawn code ENOENT.

To set up the editor integration, add something like REACT_EDITOR=atom to the .env.local file in your project folder and restart the development server. Learn more: https://goo.gl/MMTaZt

elivoa commented Jan 3, 2018

明白了,要设置REACT_EDITOR环境变量

Could not open search.js in the editor.
The editor process exited with an error: spawn code ENOENT.

To set up the editor integration, add something like REACT_EDITOR=atom to the .env.local file in your project folder and restart the development server. Learn more: https://goo.gl/MMTaZt

@hanxiansen

This comment has been minimized.

Show comment
Hide comment
@hanxiansen

hanxiansen Jan 3, 2018

由于 babel@7 无法使用 babel-plugin-add-module-exports,所有的 require('./file') 需改为 require('./file').default
感觉这个对原项目的改动会很多,暂时还是用1.3.0版本,等以后解决这个问题了再考虑升版本。

hanxiansen commented Jan 3, 2018

由于 babel@7 无法使用 babel-plugin-add-module-exports,所有的 require('./file') 需改为 require('./file').default
感觉这个对原项目的改动会很多,暂时还是用1.3.0版本,等以后解决这个问题了再考虑升版本。

@elivoa

This comment has been minimized.

Show comment
Hide comment
@elivoa

elivoa Jan 3, 2018

dllPlugin (学习成本太高,并且有其他方法可以提升 dev server 启动速度)

有什么办法可以提高dev server速度的么?现在没了dll plugin,启动速度和重新编译速度都很慢。我的项目要半分钟了。原来使用dllplugin的时候是重编速度6-7秒。

elivoa commented Jan 3, 2018

dllPlugin (学习成本太高,并且有其他方法可以提升 dev server 启动速度)

有什么办法可以提高dev server速度的么?现在没了dll plugin,启动速度和重新编译速度都很慢。我的项目要半分钟了。原来使用dllplugin的时候是重编速度6-7秒。

@sorrycc

This comment has been minimized.

Show comment
Hide comment
@sorrycc

sorrycc Jan 4, 2018

Owner

有什么办法可以提高dev server速度的么?现在没了dll plugin,启动速度和重新编译速度都很慢。我的项目要半分钟了。原来使用dllplugin的时候是重编速度6-7秒。

按需编译,umi 里有实现。

Owner

sorrycc commented Jan 4, 2018

有什么办法可以提高dev server速度的么?现在没了dll plugin,启动速度和重新编译速度都很慢。我的项目要半分钟了。原来使用dllplugin的时候是重编速度6-7秒。

按需编译,umi 里有实现。

@sorrycc

This comment has been minimized.

Show comment
Hide comment
@sorrycc

sorrycc Jan 4, 2018

Owner

感觉这个对原项目的改动会很多,暂时还是用1.3.0版本,等以后解决这个问题了再考虑升版本。

require 用的地方应该不多吧,大部分应该是 import 才对。而且 require().default 是标准的写法,应该不会再回去了,拥抱变化吧,🤗

Owner

sorrycc commented Jan 4, 2018

感觉这个对原项目的改动会很多,暂时还是用1.3.0版本,等以后解决这个问题了再考虑升版本。

require 用的地方应该不多吧,大部分应该是 import 才对。而且 require().default 是标准的写法,应该不会再回去了,拥抱变化吧,🤗

@HeskeyBaozi

This comment has been minimized.

Show comment
Hide comment
@HeskeyBaozi

HeskeyBaozi Jan 4, 2018

👍 2.0 普天同庆

  • commons 这个选项给了代码块分割手动干预的更多定制
  • definealias 简直是目录结构强迫症的福音
    除了create-react-app外,用来快速迭代,接近0配置的不二选择。

HeskeyBaozi commented Jan 4, 2018

👍 2.0 普天同庆

  • commons 这个选项给了代码块分割手动干预的更多定制
  • definealias 简直是目录结构强迫症的福音
    除了create-react-app外,用来快速迭代,接近0配置的不二选择。
@iceberg211

This comment has been minimized.

Show comment
Hide comment
@iceberg211

iceberg211 Jan 4, 2018

不支持装饰器的写法了吗?

iceberg211 commented Jan 4, 2018

不支持装饰器的写法了吗?

@sorrycc

This comment has been minimized.

Show comment
Hide comment
@sorrycc

sorrycc Jan 4, 2018

Owner

不支持装饰器的写法了吗?

要额外引 babel 插件的,1.0 的时候也是这样。

Owner

sorrycc commented Jan 4, 2018

不支持装饰器的写法了吗?

要额外引 babel 插件的,1.0 的时候也是这样。

@sorrycc

This comment has been minimized.

Show comment
Hide comment
@sorrycc

sorrycc Jan 4, 2018

Owner

commons 可以提高开发时修改之后重新编译的时间么?

不能。

Owner

sorrycc commented Jan 4, 2018

commons 可以提高开发时修改之后重新编译的时间么?

不能。

@iceberg211

This comment has been minimized.

Show comment
Hide comment
@iceberg211

iceberg211 Jan 5, 2018

要额外引 babel 插件的,1.0 的时候也是这样。
是babel-plugin-transform-decorators-legacy吧,我在.webpackrc这样配的

  "extraBabelPlugins": [
        "transform-decorators-legacy",
        "lodash", ["import", { "libraryName": "antd-mobile", "style": true }]
    ],

其他的步骤也照做了

iceberg211 commented Jan 5, 2018

要额外引 babel 插件的,1.0 的时候也是这样。
是babel-plugin-transform-decorators-legacy吧,我在.webpackrc这样配的

  "extraBabelPlugins": [
        "transform-decorators-legacy",
        "lodash", ["import", { "libraryName": "antd-mobile", "style": true }]
    ],

其他的步骤也照做了

@bibiehy

This comment has been minimized.

Show comment
Hide comment
@bibiehy

bibiehy Jan 5, 2018

dva new 创建项目后,手动升级roadhog@2.0.3,严格按照上面修改,但编译失败了。

image
.webpackrc 文件配置:
image

bibiehy commented Jan 5, 2018

dva new 创建项目后,手动升级roadhog@2.0.3,严格按照上面修改,但编译失败了。

image
.webpackrc 文件配置:
image

@sorrycc

This comment has been minimized.

Show comment
Hide comment
@sorrycc

sorrycc Jan 5, 2018

Owner

@bibiehy 如果有 babel-runtime 依赖和配置了 babel-plugin-transform-runtime 插件,需删除,因为已内置处理,否则可能会报 this.setDynamic is not a function 的错误

Owner

sorrycc commented Jan 5, 2018

@bibiehy 如果有 babel-runtime 依赖和配置了 babel-plugin-transform-runtime 插件,需删除,因为已内置处理,否则可能会报 this.setDynamic is not a function 的错误

@bibiehy

This comment has been minimized.

Show comment
Hide comment
@bibiehy

bibiehy Jan 5, 2018

@sorrycc 谢谢,2个都删除掉,修改"extraBabelPlugins": ["@babel/transform-runtime"]就好了。

还一个问题,js 校验工具ESLint 的配置在哪里修改或者禁用。

@+babel/transform-runtime不见了。|- _ -

bibiehy commented Jan 5, 2018

@sorrycc 谢谢,2个都删除掉,修改"extraBabelPlugins": ["@babel/transform-runtime"]就好了。

还一个问题,js 校验工具ESLint 的配置在哪里修改或者禁用。

@+babel/transform-runtime不见了。|- _ -

@sorrycc

This comment has been minimized.

Show comment
Hide comment
@sorrycc

sorrycc Jan 5, 2018

Owner

可以 DISABLE_ESLINT roadhog dev 禁用,修改的话本地配 .eslintrc 就好了。

Owner

sorrycc commented Jan 5, 2018

可以 DISABLE_ESLINT roadhog dev 禁用,修改的话本地配 .eslintrc 就好了。

@Tsury

This comment has been minimized.

Show comment
Hide comment
@Tsury

Tsury Jan 6, 2018

No more --watch for roadhog build? I need that...
I'm building for a non-browser app and I need to build on every change. The watch option made it very fast. Now if I set a watch task, it rebuilds everything on every change, which is too slow for me.

Tsury commented Jan 6, 2018

No more --watch for roadhog build? I need that...
I'm building for a non-browser app and I need to build on every change. The watch option made it very fast. Now if I set a watch task, it rebuilds everything on every change, which is too slow for me.

@sorrycc

This comment has been minimized.

Show comment
Hide comment
@sorrycc

sorrycc Jan 7, 2018

Owner

@Tsury thanks for feedback, it's supported in roadhog@2.0.6 .

Owner

sorrycc commented Jan 7, 2018

@Tsury thanks for feedback, it's supported in roadhog@2.0.6 .

@Tsury

This comment has been minimized.

Show comment
Hide comment
@Tsury

Tsury Jan 8, 2018

@sorrycc thanks! Another request - is it possible to build in debug? I'm trying to build, but it only builds for production.

I see this line in af-webpack build.js line 32:
process.env.NODE_ENV = 'production'; // These sizes are pretty large. We'll warn for bundles exceeding them.

Then in af-webpack's getConfig.js file line 66:
const isDev = process.env.NODE_ENV === 'development';

And then everything in the config is optimized for release (uglified, etc...) because isDev === false.

Is there a way to build debug output files (no dev server)? No compression, no optimizations.

Tsury commented Jan 8, 2018

@sorrycc thanks! Another request - is it possible to build in debug? I'm trying to build, but it only builds for production.

I see this line in af-webpack build.js line 32:
process.env.NODE_ENV = 'production'; // These sizes are pretty large. We'll warn for bundles exceeding them.

Then in af-webpack's getConfig.js file line 66:
const isDev = process.env.NODE_ENV === 'development';

And then everything in the config is optimized for release (uglified, etc...) because isDev === false.

Is there a way to build debug output files (no dev server)? No compression, no optimizations.

@sorrycc

This comment has been minimized.

Show comment
Hide comment
@sorrycc

sorrycc Jan 8, 2018

Owner

@Tsury No compression is supported by NO_COMPRESS=1 roadhog build.

Owner

sorrycc commented Jan 8, 2018

@Tsury No compression is supported by NO_COMPRESS=1 roadhog build.

@Tsury

This comment has been minimized.

Show comment
Hide comment
@Tsury

Tsury Jan 8, 2018

It's still not enough.
There are properties in the config that are determined solely by 'isDev', which is false. When I set NO_COMPRESS=1, my binary get's just a little bigger (~1.7mb), but it still very optimized. When I force isDev === true, the binary get's huge (5.5mb), and there's no compression.

Also, another issue - because of:
process.env.NODE_ENV = 'production'; // These sizes are pretty large. We'll warn for bundles exceeding them.

This line forces my ENV to be production, and then my 'production' configuration in .webpackrc.js is used, instead of my development configuration.

Something here looks a little awkward to me.

EDIT: I would just like to control the NODE_ENV myself, and build debug, without af-webpack forcing it to be 'production'...
EDIT 2: This forcing of NODE_ENV will also make React run in production mode. To summarize - I can't currently use roadhog build and have NODE_ENV = 'development'
LAST EDIT: I believe all of this is caused because now roadhog build --debug was removed.

Tsury commented Jan 8, 2018

It's still not enough.
There are properties in the config that are determined solely by 'isDev', which is false. When I set NO_COMPRESS=1, my binary get's just a little bigger (~1.7mb), but it still very optimized. When I force isDev === true, the binary get's huge (5.5mb), and there's no compression.

Also, another issue - because of:
process.env.NODE_ENV = 'production'; // These sizes are pretty large. We'll warn for bundles exceeding them.

This line forces my ENV to be production, and then my 'production' configuration in .webpackrc.js is used, instead of my development configuration.

Something here looks a little awkward to me.

EDIT: I would just like to control the NODE_ENV myself, and build debug, without af-webpack forcing it to be 'production'...
EDIT 2: This forcing of NODE_ENV will also make React run in production mode. To summarize - I can't currently use roadhog build and have NODE_ENV = 'development'
LAST EDIT: I believe all of this is caused because now roadhog build --debug was removed.

@lusess123

This comment has been minimized.

Show comment
Hide comment
@lusess123

lusess123 Apr 21, 2018

@jiangzm roadhog 黑盒化 webpack , 竞品是 facebook 的create-react-app , 本身也提供了webpack.config.js 的完全扩展。

lusess123 commented Apr 21, 2018

@jiangzm roadhog 黑盒化 webpack , 竞品是 facebook 的create-react-app , 本身也提供了webpack.config.js 的完全扩展。

@zhouyi318

This comment has been minimized.

Show comment
Hide comment
@zhouyi318

zhouyi318 Apr 21, 2018

zhouyi318 commented Apr 21, 2018

@jiangzm

This comment has been minimized.

Show comment
Hide comment
@jiangzm

jiangzm Apr 22, 2018

@lusess123 @zhouyi318
谢谢两位!
另外想问下roadhog有释放配置的命令吗?好像没找到类似eject的命令。

jiangzm commented Apr 22, 2018

@lusess123 @zhouyi318
谢谢两位!
另外想问下roadhog有释放配置的命令吗?好像没找到类似eject的命令。

@WeiJieGitHub

This comment has been minimized.

Show comment
Hide comment
@WeiJieGitHub

WeiJieGitHub Apr 22, 2018

我想要自定义 webpack 配置应该如何操作,比如我想加上 stylelint,我通过 webpack.config.js 的方式没有成功,如下:
webpack.config.js

const StyleLintPlugin = require('stylelint-webpack-plugin');
export default function (webpackConfig, env) {
  webpackConfig.plugins.push(new StyleLintPlugin());
  return webpackConfig;
}

这是我的目录结构
image

WeiJieGitHub commented Apr 22, 2018

我想要自定义 webpack 配置应该如何操作,比如我想加上 stylelint,我通过 webpack.config.js 的方式没有成功,如下:
webpack.config.js

const StyleLintPlugin = require('stylelint-webpack-plugin');
export default function (webpackConfig, env) {
  webpackConfig.plugins.push(new StyleLintPlugin());
  return webpackConfig;
}

这是我的目录结构
image

@zhouyi318

This comment has been minimized.

Show comment
Hide comment
@zhouyi318

zhouyi318 Apr 23, 2018

zhouyi318 commented Apr 23, 2018

@xiangweijun

This comment has been minimized.

Show comment
Hide comment

xiangweijun commented Apr 23, 2018

@Pecking

This comment has been minimized.

Show comment
Hide comment
@Pecking

Pecking May 4, 2018

jzo4 v xk 5 mo0j k67
fqr 6d91dskz_cvwt w d
这样手动删除了babel-plugin-transform-runtime,他会报错不存在这个依赖;怎么解决了?

Pecking commented May 4, 2018

jzo4 v xk 5 mo0j k67
fqr 6d91dskz_cvwt w d
这样手动删除了babel-plugin-transform-runtime,他会报错不存在这个依赖;怎么解决了?

@zhouyi318

This comment has been minimized.

Show comment
Hide comment
@zhouyi318

zhouyi318 May 4, 2018

zhouyi318 commented May 4, 2018

@Pecking

This comment has been minimized.

Show comment
Hide comment
@Pecking

Pecking May 4, 2018

@zhouyi318 我没用babel-polyfill,但是我用了babel-runtime ,如果我删除 babel-plugin-transform-runtime 这个依赖,启动得时候会报错不存在这个依赖,怎么解决了

Pecking commented May 4, 2018

@zhouyi318 我没用babel-polyfill,但是我用了babel-runtime ,如果我删除 babel-plugin-transform-runtime 这个依赖,启动得时候会报错不存在这个依赖,怎么解决了

@zhouyi318

This comment has been minimized.

Show comment
Hide comment
@zhouyi318

zhouyi318 May 4, 2018

zhouyi318 commented May 4, 2018

@zhouyi318

This comment has been minimized.

Show comment
Hide comment
@zhouyi318

zhouyi318 May 4, 2018

zhouyi318 commented May 4, 2018

@minlx

This comment has been minimized.

Show comment
Hide comment
@minlx

minlx May 7, 2018

我在webpackrc里面配置了transform-decorators-legacy之后每个页面配置的就那不到了,
20180507122257

但是删掉transform-decorators-legacy的配置就好了,这是为什么

minlx commented May 7, 2018

我在webpackrc里面配置了transform-decorators-legacy之后每个页面配置的就那不到了,
20180507122257

但是删掉transform-decorators-legacy的配置就好了,这是为什么

@Otobelikethee

This comment has been minimized.

Show comment
Hide comment
@Otobelikethee

Otobelikethee May 9, 2018

@sorrycc HI,我从atool-build+dora 切换到roadhog@2.3.0,npm start的时候,babel报错,看起来像是不支持CommonJS和ES Module混用,但是没有提示具体代码,我也没找到解决的办法。。

image

---2018.05.09 Updated---

已解决,由于roadhog内置的babel7,需要对babel-plugin-import进行升级 (Modular import plugin for babel, compatible with antd, antd-mobile, and so on.)

Otobelikethee commented May 9, 2018

@sorrycc HI,我从atool-build+dora 切换到roadhog@2.3.0,npm start的时候,babel报错,看起来像是不支持CommonJS和ES Module混用,但是没有提示具体代码,我也没找到解决的办法。。

image

---2018.05.09 Updated---

已解决,由于roadhog内置的babel7,需要对babel-plugin-import进行升级 (Modular import plugin for babel, compatible with antd, antd-mobile, and so on.)

@zhouyi318

This comment has been minimized.

Show comment
Hide comment
@zhouyi318

zhouyi318 May 9, 2018

zhouyi318 commented May 9, 2018

@qhy90223

This comment has been minimized.

Show comment
Hide comment
@qhy90223

qhy90223 May 9, 2018

请问下没有了library,如果使用roadhog打包dva模块给被人用,如何配置roadhog代替library ?

qhy90223 commented May 9, 2018

请问下没有了library,如果使用roadhog打包dva模块给被人用,如何配置roadhog代替library ?

@feitingjun

This comment has been minimized.

Show comment
Hide comment
@feitingjun

feitingjun May 14, 2018

不知道为什么,打包后的在ie里面显示不出来,包括ie11,空白的什么都没有,

tim
就报了个这个错,这是什么情况呢?

feitingjun commented May 14, 2018

不知道为什么,打包后的在ie里面显示不出来,包括ie11,空白的什么都没有,

tim
就报了个这个错,这是什么情况呢?

@feitingjun

This comment has been minimized.

Show comment
Hide comment
@feitingjun

feitingjun May 14, 2018

部署到服务器和一样的问题

feitingjun commented May 14, 2018

部署到服务器和一样的问题

@sorrycc

This comment has been minimized.

Show comment
Hide comment
@sorrycc
Owner

sorrycc commented May 14, 2018

@feitingjun

This comment has been minimized.

Show comment
Hide comment
@feitingjun

feitingjun May 14, 2018

在开发环境跑是没有问题的,也没有警告,不用dva直接在入口index.js文件中写ReactDom都出不来,而且在其他浏览器也是没有问题的

feitingjun commented May 14, 2018

在开发环境跑是没有问题的,也没有警告,不用dva直接在入口index.js文件中写ReactDom都出不来,而且在其他浏览器也是没有问题的

@xiangweijun

This comment has been minimized.

Show comment
Hide comment
@xiangweijun

xiangweijun May 21, 2018

roadhog升级至2.4.1后,配置文件webpackrc里,env下的production配置为什么不起作用了吗,
env: {
production: {
outputPath: path.join(__dirname, dist/1.0.0),
}
}
为什么正式环境打包后,输出目录是dist,而不是dist/1.0.0 @sorrycc

xiangweijun commented May 21, 2018

roadhog升级至2.4.1后,配置文件webpackrc里,env下的production配置为什么不起作用了吗,
env: {
production: {
outputPath: path.join(__dirname, dist/1.0.0),
}
}
为什么正式环境打包后,输出目录是dist,而不是dist/1.0.0 @sorrycc

@xieyunjie

This comment has been minimized.

Show comment
Hide comment
@xieyunjie

xieyunjie May 29, 2018

你升级到最新版本就可以了。

xieyunjie commented May 29, 2018

你升级到最新版本就可以了。

@dsmelon

This comment has been minimized.

Show comment
Hide comment
@dsmelon

dsmelon Jun 4, 2018

那个commons的配置可不可以写的更清楚一些呢,比如我想把moment库提出来

dsmelon commented Jun 4, 2018

那个commons的配置可不可以写的更清楚一些呢,比如我想把moment库提出来

@99874405

This comment has been minimized.

Show comment
Hide comment
@99874405

99874405 Jun 8, 2018

roadhog 建构完的包很大,怎样使用tree-shaking

99874405 commented Jun 8, 2018

roadhog 建构完的包很大,怎样使用tree-shaking

@big-tutu

This comment has been minimized.

Show comment
Hide comment
@big-tutu

big-tutu Jun 26, 2018

"dllPlugin (学习成本太高,并且有其他方法可以提升 dev server 启动速度)", 这里的其他方法,还请给一些指导,谢谢!

big-tutu commented Jun 26, 2018

"dllPlugin (学习成本太高,并且有其他方法可以提升 dev server 启动速度)", 这里的其他方法,还请给一些指导,谢谢!

@SherryJiang1130

This comment has been minimized.

Show comment
Hide comment
@SherryJiang1130

SherryJiang1130 Jul 7, 2018

不能打包多页面入口文件吗?这样配置build之后只有一个html文件,下面html,也不能配置两个.ejs文件,需要打包出两个html文件,怎么搞?
image

SherryJiang1130 commented Jul 7, 2018

不能打包多页面入口文件吗?这样配置build之后只有一个html文件,下面html,也不能配置两个.ejs文件,需要打包出两个html文件,怎么搞?
image

@capaten

This comment has been minimized.

Show comment
Hide comment
@capaten

capaten Aug 10, 2018

@sorrycc 您好,我刚接触这个,不是太懂,想请教您一下:我想使用antd-theme-webpack-plugin插件来修改主题,但不知道该怎么配置,文档里给的使用方法如下:
`const themePlugin = new AntDesignThemePlugin(options);
// in config object
plugins: [
themePlugin
]

Add this plugin in `plugins` array.`
但我的.webpackrc.js配置文件里没有plugins,内容如下:
`export default {
  entry: 'src/index.js',
  extraBabelPlugins: [
    "@babel/plugin-transform-runtime",
    ['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }],
  ],
  env: {
    development: {
      extraBabelPlugins: ['dva-hmr'],
    }
  },

  externals: {
    '@antv/data-set': 'DataSet',
    rollbar: 'rollbar',
  },
  alias: {
    components: path.resolve(__dirname, 'src/components/'),
  },
  ignoreMomentLocale: true,
  theme: './src/theme.js',
  html: {
    template: './src/index.ejs',
  },
  lessLoaderOptions: {
    javascriptEnabled: true,
  },
  disableDynamicImport: true,
  disableCSSModules:false,
  publicPath: '/',
  hash: true,
};`
请问themePlugin该放在哪个里面?

capaten commented Aug 10, 2018

@sorrycc 您好,我刚接触这个,不是太懂,想请教您一下:我想使用antd-theme-webpack-plugin插件来修改主题,但不知道该怎么配置,文档里给的使用方法如下:
`const themePlugin = new AntDesignThemePlugin(options);
// in config object
plugins: [
themePlugin
]

Add this plugin in `plugins` array.`
但我的.webpackrc.js配置文件里没有plugins,内容如下:
`export default {
  entry: 'src/index.js',
  extraBabelPlugins: [
    "@babel/plugin-transform-runtime",
    ['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }],
  ],
  env: {
    development: {
      extraBabelPlugins: ['dva-hmr'],
    }
  },

  externals: {
    '@antv/data-set': 'DataSet',
    rollbar: 'rollbar',
  },
  alias: {
    components: path.resolve(__dirname, 'src/components/'),
  },
  ignoreMomentLocale: true,
  theme: './src/theme.js',
  html: {
    template: './src/index.ejs',
  },
  lessLoaderOptions: {
    javascriptEnabled: true,
  },
  disableDynamicImport: true,
  disableCSSModules:false,
  publicPath: '/',
  hash: true,
};`
请问themePlugin该放在哪个里面?
@micheal-zhibin

This comment has been minimized.

Show comment
Hide comment
@micheal-zhibin

micheal-zhibin Aug 23, 2018

在index.js中引用了sass文件
import './css/index.scss';
用的html模板index.ejs
编译之后看到html多出一个style标签,里面存的都是我的sass文件内容而没有编译过
我的配置如下:
{
"entry": "./src/index.js",
"define": {
"process.env.NODE_ENV": "development"
},
"html": {
"template": "./src/index.template.ejs"
},
"disableCSSModules": true
}
我配置中加上sass也没用,配置如下:
{
"entry": "./src/index.js",
"define": {
"process.env.NODE_ENV": "development"
},
"html": {
"template": "./src/index.template.ejs"
},
"disableCSSModules": true,
"sass": {
"file": "./src/css/index.scss"
}
}

micheal-zhibin commented Aug 23, 2018

在index.js中引用了sass文件
import './css/index.scss';
用的html模板index.ejs
编译之后看到html多出一个style标签,里面存的都是我的sass文件内容而没有编译过
我的配置如下:
{
"entry": "./src/index.js",
"define": {
"process.env.NODE_ENV": "development"
},
"html": {
"template": "./src/index.template.ejs"
},
"disableCSSModules": true
}
我配置中加上sass也没用,配置如下:
{
"entry": "./src/index.js",
"define": {
"process.env.NODE_ENV": "development"
},
"html": {
"template": "./src/index.template.ejs"
},
"disableCSSModules": true,
"sass": {
"file": "./src/css/index.scss"
}
}

@xuxucong

This comment has been minimized.

Show comment
Hide comment
@xuxucong

xuxucong Sep 12, 2018

如果你有用 babel-polyfill,更换为 @babel/polyfill如果有 babel-runtime 依赖和配置了 babel-plugin-transform-runtime 插件,需删除,因为已内置处理,否则可能会报 this.setDynamic is not a function 的错误由于 babel@7 无法使用 babel-plugin-add-module-exports,所有的 require('./file') 需改为 require('./file').default如果有用 babel-plugin-dva-hmr,请升级到 0.4.x,发自我的华为手机-------- 原始邮件 --------主题:Re: [sorrycc/blog] roadhog 2.0 发布 (#55)发件人:Pecking 收件人:sorrycc/blog 抄送:zhouyi 270061378@qq.com,Mention 这样手动删除了babel-plugin-transform-runtime,他会报错不存在这个依赖;怎么解决了? —You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread. {"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/sorrycc/blog","title":"sorrycc/blog","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"[https://github.com/sorrycc/blog"}},"updates":{"snippets":{"icon":"PERSON","message":"@Pecking in #55: jzo4 v xk 5 mo0j k67\r\nfqr%5Cr%5Cn!%5Bfqr) 6d91dskz_cvwt w d]([https://user-images.githubusercontent.com/27414779/39610962-7511ab90-4f86-11e8-8e44-db64e50cd849.png)\r\n这样手动删除了babel-plugin-transform-runtime,他会报错不存在这个依赖;怎么解决了?"}],"action":{"name":"View](https://user-images.githubusercontent.com/27414779/39610962-7511ab90-4f86-11e8-8e44-db64e50cd849.png)%5Cr%5Cn%E8%BF%99%E6%A0%B7%E6%89%8B%E5%8A%A8%E5%88%A0%E9%99%A4%E4%BA%86babel-plugin-transform-runtime,%E4%BB%96%E4%BC%9A%E6%8A%A5%E9%94%99%E4%B8%8D%E5%AD%98%E5%9C%A8%E8%BF%99%E4%B8%AA%E4%BE%9D%E8%B5%96;%E6%80%8E%E4%B9%88%E8%A7%A3%E5%86%B3%E4%BA%86%EF%BC%9F%22%7D%5D,%22action%22:%7B%22name%22:%22View) Issue","url":"#55 (comment)"}}}

按你说的做了还是报了this.setDynamic is not a function的错,根本就没有解决

xuxucong commented Sep 12, 2018

如果你有用 babel-polyfill,更换为 @babel/polyfill如果有 babel-runtime 依赖和配置了 babel-plugin-transform-runtime 插件,需删除,因为已内置处理,否则可能会报 this.setDynamic is not a function 的错误由于 babel@7 无法使用 babel-plugin-add-module-exports,所有的 require('./file') 需改为 require('./file').default如果有用 babel-plugin-dva-hmr,请升级到 0.4.x,发自我的华为手机-------- 原始邮件 --------主题:Re: [sorrycc/blog] roadhog 2.0 发布 (#55)发件人:Pecking 收件人:sorrycc/blog 抄送:zhouyi 270061378@qq.com,Mention 这样手动删除了babel-plugin-transform-runtime,他会报错不存在这个依赖;怎么解决了? —You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread. {"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/sorrycc/blog","title":"sorrycc/blog","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"[https://github.com/sorrycc/blog"}},"updates":{"snippets":{"icon":"PERSON","message":"@Pecking in #55: jzo4 v xk 5 mo0j k67\r\nfqr%5Cr%5Cn!%5Bfqr) 6d91dskz_cvwt w d]([https://user-images.githubusercontent.com/27414779/39610962-7511ab90-4f86-11e8-8e44-db64e50cd849.png)\r\n这样手动删除了babel-plugin-transform-runtime,他会报错不存在这个依赖;怎么解决了?"}],"action":{"name":"View](https://user-images.githubusercontent.com/27414779/39610962-7511ab90-4f86-11e8-8e44-db64e50cd849.png)%5Cr%5Cn%E8%BF%99%E6%A0%B7%E6%89%8B%E5%8A%A8%E5%88%A0%E9%99%A4%E4%BA%86babel-plugin-transform-runtime,%E4%BB%96%E4%BC%9A%E6%8A%A5%E9%94%99%E4%B8%8D%E5%AD%98%E5%9C%A8%E8%BF%99%E4%B8%AA%E4%BE%9D%E8%B5%96;%E6%80%8E%E4%B9%88%E8%A7%A3%E5%86%B3%E4%BA%86%EF%BC%9F%22%7D%5D,%22action%22:%7B%22name%22:%22View) Issue","url":"#55 (comment)"}}}

按你说的做了还是报了this.setDynamic is not a function的错,根本就没有解决

@pengshaosu

This comment has been minimized.

Show comment
Hide comment
@pengshaosu

pengshaosu Oct 16, 2018

roadhog 建构完的包很大,怎样使用tree-shaking

roadhog2.0这个版本支持webpack-deep-scope-plugin?

pengshaosu commented Oct 16, 2018

roadhog 建构完的包很大,怎样使用tree-shaking

roadhog2.0这个版本支持webpack-deep-scope-plugin?

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