I link js file in example/index.html this way:
<script src="../lib/src/myjsfile.js"></script>
I run app this way:
pub serve example
And I got in CLI:
[example] GET lib/src/myjsfile.js => Could not find asset mod_lib|example/lib/src/myjsfile.js.
It looks for assets in example directory and ignores part "../". How do I fix that?
Use instead a package path
<script src="packages/mod_lib/src/myjsfile.js"></script>
Every file outside the lib/
directory that imports a file from within the lib/
directory needs to use a package import.
dart2js
also recognizes package imports in above form and replaces them with the actual path in the build output directory.
I created https://github.com/dart-archive/www.dartlang.org/issues/1593
packages
was a real directory in earlier Dart versions that contained a symlink to ../lib
(and all other dependencies specified in pubspec.yaml
). A while ago it was replaced by the content of the .packages
file. You'll find an entry for the current packages name with a path to the lib
directory (and also all dependencies from pubspec.yaml
with a path to the download directory in ~/.pub-cache
).