如何订购 angular-cli 脚本
How to order angular-cli scripts
我的 angular-cli.json
有以下内容:
...
"scripts": [
...
"../node_modules/jquery-ui/ui/widget.js",
"../node_modules/jquery-ui/ui/widgets/datepicker.js",
"../node_modules/jquery-ui-timepicker-addon/dist/jquery-ui-timepicker-addon.js",
...
],
...
在 https://github.com/trentrichardson/jQuery-Timepicker-Addon/blob/master/dist/jquery-ui-timepicker-addon.js#L15 我得到 Uncaught TypeError: Cannot read property 'timepicker' of undefined
。我发现这是因为 webpack 按以下顺序加载脚本:
jquery-ui-timepicker-addon.js
widget.js
datepicker.js
widget.js
需要在 jquery-ui-timepicker-addon.js
之前加载。为什么 webpack 的加载顺序与配置的顺序不同?如何确定文件加载的顺序?
目前不支持(从 beta.24 开始)。
您可能需要打开一个新的 Github 问题以根据 angular-cli.json
配置维护脚本顺序。
您可以尝试的另一个选项是从 TypeScript 导入文件。
脚本确实按照它们在 angular-cli.json
中的顺序加载,Uncaught TypeError: Cannot read property 'timepicker' of undefined
是对 $.ui
在 jquery-ui/ui/version.js
而不是 jquery-ui/ui/widget.js
中定义的。
我的错误。
...while it does look like they are loaded in the wrong order because of the numbers, they are loaded in the right order...
https://github.com/angular/angular-cli/issues/3782#issuecomment-269883288
我的 angular-cli.json
有以下内容:
...
"scripts": [
...
"../node_modules/jquery-ui/ui/widget.js",
"../node_modules/jquery-ui/ui/widgets/datepicker.js",
"../node_modules/jquery-ui-timepicker-addon/dist/jquery-ui-timepicker-addon.js",
...
],
...
在 https://github.com/trentrichardson/jQuery-Timepicker-Addon/blob/master/dist/jquery-ui-timepicker-addon.js#L15 我得到 Uncaught TypeError: Cannot read property 'timepicker' of undefined
。我发现这是因为 webpack 按以下顺序加载脚本:
jquery-ui-timepicker-addon.js
widget.js
datepicker.js
widget.js
需要在 jquery-ui-timepicker-addon.js
之前加载。为什么 webpack 的加载顺序与配置的顺序不同?如何确定文件加载的顺序?
目前不支持(从 beta.24 开始)。
您可能需要打开一个新的 Github 问题以根据 angular-cli.json
配置维护脚本顺序。
您可以尝试的另一个选项是从 TypeScript 导入文件。
脚本确实按照它们在 angular-cli.json
中的顺序加载,Uncaught TypeError: Cannot read property 'timepicker' of undefined
是对 $.ui
在 jquery-ui/ui/version.js
而不是 jquery-ui/ui/widget.js
中定义的。
我的错误。
...while it does look like they are loaded in the wrong order because of the numbers, they are loaded in the right order... https://github.com/angular/angular-cli/issues/3782#issuecomment-269883288