所以我知道webpack服务说一个bundle.js,它有来自ECMA2015,jsx和ECMA5的所有Babel动词。此文件比原始文件大n倍,可与任何浏览器兼容。但是有些浏览器支持很多转换后的功能,因此在这种情况下额外的下载/运行量是浪费。你知道webpack是否有能力提供/创建针对任何浏览器/版本优化的不同包?
答案 0 :(得分:0)
好吧,你可以创建不同的包,但是你会如何为它们服务呢?通常捆绑包是预先构建的而不是动态,所以你要求的应该是基于浏览器的快速完成。我现在能想到的一种方法就是使用nodeJS基于User-agent在GET bundle.js上提供不同的预构建包。也许其他人有其他想法!
答案 1 :(得分:0)
您可以使用<android.support.design.widget.AppBarLayout
android:theme="@style/Base.ThemeOverlay.AppCompat.Dark"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView"
android:text="5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/Image_view"
android:src="@drawable/circule"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_single_poem"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways" />
</android.support.design.widget.AppBarLayout>
,这正是为了避免不必要的polyfill。保留Chrome 41,以便谷歌索引器正确抓取您的应用。
@babel/preset-env
可以解决问题。
您可以取消注释调试行以查看正在进行的操作。
在.babelrc中,只需添加
useBuiltIns