Vue.js Vue-cli3 Vue cli服务构建--现代版;行不通
在Vue.js Vue-cli3 Vue cli服务构建--现代版;行不通,vue.js,vue-cli,vue-cli-3,Vue.js,Vue Cli,Vue Cli 3,在npm run build--modern成功运行后,我在输出中只看到一个应用程序。不应该有两个吗? 我找不到您放在图像中的文档,但从中可以看出: --modern使用modern模式构建应用程序,将本机ES2015代码发送到支持它的现代浏览器,并自动回退到传统捆绑包 然后我会把它理解为一个灵活的应用程序 从您在评论中提到的文档中,我发现了以下相关部分: 不过最酷的部分是没有特殊的部署要求。生成的HTML文件自动采用Phillip Walton的优秀帖子中讨论的技术: 现代捆绑包在支持它的浏览
npm run build--modern
成功运行后,我在输出中只看到一个应用程序。不应该有两个吗?
我找不到您放在图像中的文档,但从中可以看出:
--modern
使用modern模式构建应用程序,将本机ES2015代码发送到支持它的现代浏览器,并自动回退到传统捆绑包
然后我会把它理解为一个灵活的应用程序
从您在评论中提到的文档中,我发现了以下相关部分:
不过最酷的部分是没有特殊的部署要求。生成的HTML文件自动采用Phillip Walton的优秀帖子中讨论的技术:
现代捆绑包在支持它的浏览器中加载了
,;它们也使用
进行预加载
传统捆绑包加载了
,,支持ES模块的浏览器会忽略它
Safari 10中的
修复程序也会自动注入
有了这一点,我可以用同样的方式来解释,一个应用程序根据浏览器的不同表现不同
说到尺寸,我不确定是否需要更多的设置来启用它,但根据文档,它不是。我鼓励您继续阅读这些文档,对我来说,这是更新任何需求的最佳方式。我找不到您放在图像中的文档,但从中可以看出:
--modern
使用modern模式构建应用程序,将本机ES2015代码发送到支持它的现代浏览器,并自动回退到传统捆绑包
然后我会把它理解为一个灵活的应用程序
从您在评论中提到的文档中,我发现了以下相关部分:
不过最酷的部分是没有特殊的部署要求。生成的HTML文件自动采用Phillip Walton的优秀帖子中讨论的技术:
现代捆绑包在支持它的浏览器中加载了
,;它们也使用
进行预加载
传统捆绑包加载了
,,支持ES模块的浏览器会忽略它
Safari 10中的
修复程序也会自动注入
有了这一点,我可以用同样的方式来解释,一个应用程序根据浏览器的不同表现不同
说到尺寸,我不确定是否需要更多的设置来启用它,但根据文档,它不是。我鼓励你继续阅读它们,对我来说,这是跟上任何需求的最好方式
在npm run build--modern
成功运行后,我在输出中只看到一个应用程序。不应该有两个吗
实际上,build--modern
命令在dist/js
中创建了两个应用程序(请参见dist/js/app.4e3aeb0e.js
和dist/js/app legacy.10b7d753.js
):
这些脚本稍后将加载到
中(注意:只有支持
的浏览器才会加载脚本):
我比较了现代和非现代的尺寸,没有区别吗
我不知道你是如何比较大小的,但现代的建筑实际上更大。在下面的示例中,我构建了一个Vue CLI生成的应用程序(使用默认设置预设)两次(一次不使用--modern
,另一次使用--modern
),并重命名了输出目录。查看index.html和js/
的dist-modern
中的大小增加:
➜ ls -al dist*
dist-default:
total 16
drwxr-xr-x 7 tony staff 224 Sep 2 19:25 .
drwxr-xr-x 13 tony staff 416 Sep 2 19:27 ..
drwxr-xr-x 3 tony staff 96 Sep 2 19:25 css
-rw-r--r-- 1 tony staff 1150 Sep 2 19:25 favicon.ico
drwxr-xr-x 3 tony staff 96 Sep 2 19:25 img
-rw-r--r-- 1 tony staff 724 Sep 2 19:25 index.html
drwxr-xr-x 6 tony staff 192 Sep 2 19:25 js
dist-modern:
total 16
drwxr-xr-x 7 tony staff 224 Sep 2 19:25 .
drwxr-xr-x 13 tony staff 416 Sep 2 19:27 ..
drwxr-xr-x 3 tony staff 96 Sep 2 19:25 css
-rw-r--r-- 1 tony staff 1150 Sep 2 19:25 favicon.ico
drwxr-xr-x 3 tony staff 96 Sep 2 19:25 img
-rw-r--r-- 1 tony staff 1213 Sep 2 19:25 index.html <-- LARGER
drwxr-xr-x 10 tony staff 320 Sep 2 19:25 js <-- LARGER
➜ ls-al区*
地区默认值:
总数16
drwxr-xr-x 7托尼·斯塔夫224年9月2日19:25。
drwxr-xr-x 13 tony staff 416 Sep 2 19:27。。
drwxr-xr-x 3 tony staff 96 Sep 2 19:25 css
-rw-r--r--1 tony staff 1150 Sep 2 19:25 favicon.ico
drwxr-xr-x 3 tony staff 96 Sep 2 19:25 img
-rw-r--r--1 tony员工724 9月2日19:25 index.html
drwxr-xr-x 6 tony staff 192 Sep 2 19:25 js
现代区:
总数16
drwxr-xr-x 7托尼·斯塔夫224年9月2日19:25。
drwxr-xr-x 13 tony staff 416 Sep 2 19:27。。
drwxr-xr-x 3 tony staff 96 Sep 2 19:25 css
-rw-r--r--1 tony staff 1150 Sep 2 19:25 favicon.ico
drwxr-xr-x 3 tony staff 96 Sep 2 19:25 img
-rw-r--r--1 tony staff 1213年9月2日19:25 index.html
在npm run build--modern
成功运行后,我在输出中只看到一个应用程序。不应该有两个吗
实际上,build--modern
命令在dist/js
中创建了两个应用程序(请参见dist/js/app.4e3aeb0e.js
和dist/js/app legacy.10b7d753.js
):
这些脚本稍后将加载到
中(注意:只有支持
的浏览器才会加载脚本):
我比较了现代和非现代的尺寸,没有区别吗
我不知道你是如何比较大小的,但现代的建筑实际上更大。在下面的示例中,我构建了一个Vue CLI生成的应用程序(使用默认设置预设)两次(一次不使用--modern
,另一次使用--modern
),并重命名了输出目录。查看index.html和js/
的dist-modern
中的大小增加:
➜ ls -al dist*
dist-default:
total 16
drwxr-xr-x 7 tony staff 224 Sep 2 19:25 .
drwxr-xr-x 13 tony staff 416 Sep 2 19:27 ..
drwxr-xr-x 3 tony staff 96 Sep 2 19:25 css
-rw-r--r-- 1 tony staff 1150 Sep 2 19:25 favicon.ico
drwxr-xr-x 3 tony staff 96 Sep 2 19:25 img
-rw-r--r-- 1 tony staff 724 Sep 2 19:25 index.html
drwxr-xr-x 6 tony staff 192 Sep 2 19:25 js
dist-modern:
total 16
drwxr-xr-x 7 tony staff 224 Sep 2 19:25 .
drwxr-xr-x 13 tony staff 416 Sep 2 19:27 ..
drwxr-xr-x 3 tony staff 96 Sep 2 19:25 css
-rw-r--r-- 1 tony staff 1150 Sep 2 19:25 favicon.ico
drwxr-xr-x 3 tony staff 96 Sep 2 19:25 img
-rw-r--r-- 1 tony staff 1213 Sep 2 19:25 index.html <-- LARGER
drwxr-xr-x 10 tony staff 320 Sep 2 19:25 js <-- LARGER
➜ ls-al区*
地区默认值:
总数16
drwxr-xr-x 7托尼·斯塔夫224年9月2日19:25。
drwxr-xr-x 13 tony staff 416 Sep 2 19:27。。
drwxr-xr-x 3 tony staff 96 Sep 2 19:25 css
-rw-r--r--1 tony staff 1150 Sep 2 19:25 favicon.ico
drwxr-xr-x 3 tony staff 96 Sep 2 19:25 img
-rw-r--r--1 tony staff 724 Sep 2 19:25 index.html
drwxr-xr-x 6 tony staff 192 Sep 2 19:25 js
现代区:
总数16
drwxr-xr-x 7托尼·斯塔夫224年9月2日19:25。
drwxr-xr-x 13 tony staff 416 Sep 2 19:27。。
drwxr-xr-x 3 tony staff 96 Sep 2 19:25 css
-rw
<script type=module src=/js/chunk-vendors.4fd390fb.js></script>
<script type=module src=/js/app.4e3aeb0e.js></script>
<script>!function () { var e = document, t = e.createElement("script"); if (!("noModule" in t) && "onbeforeload" in t) { var n = !1; e.addEventListener("beforeload", function (e) { if (e.target === t) n = !0; else if (!e.target.hasAttribute("nomodule") || !n) return; e.preventDefault() }, !0), t.type = "module", t.src = ".", e.head.appendChild(t), t.remove() } }();</script>
<script src=/js/chunk-vendors-legacy.df5f2e07.js nomodule></script>
<script src=/js/app-legacy.10b7d753.js nomodule></script>
➜ ls -al dist*
dist-default:
total 16
drwxr-xr-x 7 tony staff 224 Sep 2 19:25 .
drwxr-xr-x 13 tony staff 416 Sep 2 19:27 ..
drwxr-xr-x 3 tony staff 96 Sep 2 19:25 css
-rw-r--r-- 1 tony staff 1150 Sep 2 19:25 favicon.ico
drwxr-xr-x 3 tony staff 96 Sep 2 19:25 img
-rw-r--r-- 1 tony staff 724 Sep 2 19:25 index.html
drwxr-xr-x 6 tony staff 192 Sep 2 19:25 js
dist-modern:
total 16
drwxr-xr-x 7 tony staff 224 Sep 2 19:25 .
drwxr-xr-x 13 tony staff 416 Sep 2 19:27 ..
drwxr-xr-x 3 tony staff 96 Sep 2 19:25 css
-rw-r--r-- 1 tony staff 1150 Sep 2 19:25 favicon.ico
drwxr-xr-x 3 tony staff 96 Sep 2 19:25 img
-rw-r--r-- 1 tony staff 1213 Sep 2 19:25 index.html <-- LARGER
drwxr-xr-x 10 tony staff 320 Sep 2 19:25 js <-- LARGER