Add a page to Next.js with Webpack plugin - javascript

Is there a way to generate a file dynamically and inject it into /pages without saving it in this directory?
For example, if I'd like to create a Next.js plugin that adds example.com/build static page with timestamp of last compilation, or list file structure of the project.

Related

Angular 8 not under rootDir when i add json file

I have added some json file to my library, but when I build it there is error my.json file not under rootDir.
Assuming you want to access the .json file as part of the application build process (i.e. not via http), you will will need to put it into the assets folder in your project.
More information about the folder structure of an Angular application here.
You can then follow the instructions here to access the data from your components.

Including source files in Cordova project from outside the project's directory hierarchy

tl;dr: I want to include some JavaScript files from another project in another directory into a Cordova project, without (manually) copying those files into my Cordova project directory tree. How?
I am editing an existing Cordova project that makes use of some JavaScript source files originally written for a large web application project.
Currently, I am adding these source files by copying them to a subdirectory of the Cordova project, and by adding a <script> tag with the relative path to an index.html file in the Cordova project. This causes the JavaScript files to integrated in the deployed app, apparently by virtue of Cordova's (or Ionic's?) magic.
Now, it would be preferrable for me to avoid copying the JavaScript files to my Cordova project directory. Instead, I would like to directly link to the files in their original location rather than copying them (so updates from the web application get automatically applied to the Cordova project, as well).
As both the Cordova project and the large web application reside in the same VCS repository, the relative path to the files will always be the same - for the sake of an example, like this:
|-repository/
|-web/
| |-src/
| |-myCode.js
|-cordova
|-src
|-index.html
|-helpers
|-myCode.js // copy of /repository/web/src/myCode.js
Therefore, I have tried setting the relative path in the aforementioned index.html file - but unfortunately, Cordova seems to take over that file verbatim, and thus, the resulting URL will not exist (prompting a 404 error in the console, and causing the code from the file to be unavailable).
How can I have Cordova include and reference files from outside the directory hierarchy of a Cordova project?
Is there maybe at least a way to have Ionic or Cordova automatically copy the files into the Cordova project directory upon building the app?

Npm package for run specific entry

I use webpack to bundle all js for a multi page app. Is there a package that can help "routing" which script should run on page load? For example adding an atribute to body element like "data-load-entry"?
HTML Webpack Plugin can be used to generate HTML files that load your JS bundle.
By combining Generating Multiple HTML Files and Writing Your Own Templates, you should be able to generate multiple HTML files that are customized so the code in your bundle can determine what to run.

PDF Viewer for Ionic 2: cannot import or require

I am trying to build a PDF viewing component for an Ionic 2 app. I have lots of experience of Angular 2, but not of Ionic.
The component will be built using pdf.js and have created the pdf.js asset to be included in my project as described on the github page. However, trying to require this fails — require is not defined —, so I copied the script to the asset folder and tried importing it. It seems the file is not being copied to the build so that fails too.
Anyone have any pointers for requiring or importing a non-weboack non-SystemJS script into an Ionic 2 app?
Create a js folder (or something like this) in the www folder; include the files needed and reference them from there. This folder is not emptied on build.
EDIT
The root of the www folder does not change and you can reference it as someting like ... 'js/need-this.js'.
There should have some references in your index.html file to the build folder and maybe the assets folder (icon); this concept of using a js folder works the same. Only build and assets will change.
I feel that I should point out that you shouldn't copy anything into www since this is autogenerated and any changes will be overwritten. You should copy into assets instead.

How can I change the bootstrap font include urls from relative to absolute when using the Aurelia cli

I'm building a application using Aurelia and the Aurelia cli. Using the workaround described here I'm able to copy the fonts from bootstrap to the correct location (/bootstrap/fonts) and it works as expected when loading the root of the site. The paths in bootstrap.css will however all be relative (bootstrap/fonts) which means that when I load any other url, lets say "/products", the fonts will be loaded from "/products/bootstrap/fonts" where they obviously wont be found. Is there any way I can change the urls in bootstrap.css when building with the Aurelia cli? I would just like to add "/" in front of any url.
You need to add bootstrap resources (css and fonts) manually to index.html file and add new build stage to build.js file instead of aurelia.json config file.
You can find code example for font-awesome here (bootstrap files will be have the same code).

Categories