Is it possible to build a website purely made from HTML/CSS/JS with npm?
I want to use some npm modules in my 1 javascript file, but I don't know which built tool I need to use and how in order to end with just 1 JS file.
Thanks for the help!
Related
I started a web app using Laravel 6 years ago and trying to optimize it and update the technologies around it. I was searching for minifying my .css and .js files (or any minifyable files) without using NPM since I do not have NPM installed in my project and that it is not a Node project.
What are my options?
Can I integrate NPM in my project?
Is there another way to minify without using NPM?
If I integrate NPM in my project, since I did not create my project with NPM, is it easy to do it?
Thanks for helping me out :)
My web development is principally intranet sites and web front-ends for embedded devices using NodeJS.
My current structure is to have everything in one NPM package. I run NodeJS behind Nginx, and let Nginx serve css/image/client-side-javascript files directly from public.
I'm starting to use VueJS and Vuelidate, both of which use the now ES6 modules system - e.g. import { required, minLength } from 'vuelidate/lib/validators'.
While I've (rather hackily) made these work with my current structure, I think the time has come to get into the world of Javascript build-systems/bundlers.
If I use VueJS's preferred option of WebPack, how should I change the structure of my code?
Should I have one NPM package for the frontend (generated by vue-cli init) and another for the Express backend app?
Should I put my Express App into the generated Vue frontend package?
Should I use browserify to do the job of WebPack and stay with my existing structure?
Or something else entirely?
I’m not sure why you’re intent on putting your JavaScript code in other packages. If you have an application then you can keep your raw JavaScript files in there, along with the build script(s). Someone should be able to check your application out and be able to build it.
If you’re looking to get started with a build system, then a nice “bridge” might be to use Mix, a project created by Laravel for building front-end assets such as Sass and JavaScript. It uses Webpack under the hood, but in turn exposes a more user-friendly, fluid API.
If you go down this route, then you could put your raw JavaScript files in a lib/ or src/ directory. You could then use Mix to compile these components like this:
mix.js('lib/your-entry-point-script.js', 'public/js/app.js');
Your entry point script would just be the script that requires all your other scripts and components and the script that you want “built”. Mix would then compile that and place the resultant script at public/js/app.js.
Mix itself is just a npm package, so all you need to do is npm install laravel-mix --save-dev.
You can read more about Mix at https://laravel.com/docs/5.7/mix
I'm a back-end java developer (spring boot) and currently I'm interested in building a single page application.
What I like about SPA frameworks (mostly Vue):
Model-binding (saves boilerplate code)
Components and templates (separating code in multiple files is always good, but I don't like single file components as I feel they mix the view and logic)
Routers
However, unless you are using Node there seems to be poor integration
What I don't like:
Node (I develop backend in Java so I don't want to install node just as a prerequisite for NPM)
NPM (I already have dependency management in Maven/Gradle. I actually don't mind it as much, I just don't want to install it and manage it seperately)
I understand why stuff like Node, Npm, Webpack is necessary, it's just that I've already have Java/Spring/Eclipse doing all that for me. I have no desire to have basically two separate build processes.
TLDR: I like the direction and architecture of modern frontend, I just don't want to deal with the tools that are used.
Specific Question: How can I develop a modern SPA using Spring Boot, Gradle/Maven and Vue.js and not have to install Node/Npm/Vue cli etc. What are the best tools if there are any?
Thank you.
You can use maven frontend plugin hosted from here.
It is maven plugin that is leveraging downloading nodejs, webpack, gulp, grunt and running it on your codebase.
You will be able to run maven build and nodejs will be downloaded automatically. It will run your frontend build as well and in resulting jar you will have only necessary minified files.
However, you have to be aware that if you want to debug your frontend application it is a good idea to have those things installed and being able to run the app locally without minification of html and js files.
If you don`t want to download tools you can use helper scripts provided by authors of this plugin to use tools downloaded by this plugin.
Currently, my web app consists of java with a html/css/js front end. I am trying to convert my application over to angular 4 while still using java instead of node.js/npm. This is my first time building an Angular 4 app and I am having some issues :( "I've created tutorial/demo apps before but this is my first time converting an entire web app to Angular 4."
I know that using node.js and npm is seen as the easy solution when working with Angular 4, but I need to use java instead of node.js/npm.
The issue I'm having:
I entered some sample code for Angular 4 into my application and when I attempt to build it using the "ng-install", I get a error that says "node_modules appears empty, you may need to run npm install".
I do not want to use node.js or npm in my project. Instead I want to keep using Java.
Does anyone have any examples or advice? All help is appreciated.
I think you mix up a couple of things: Java is the language which you use to build your backend. Do this, that's fine. JavaScript is language which is used for your frontend. Your problem is building the project. NPM is a package manager for JavaScript libraries. Even if you use NPM, it doesn't mean that you cannot use Java. Those are two different things.
Usually you would use Maven (or Gradle) to build your Java project and NPM or Bower to build your frontend. If you don't want to use NPM (because it needs NodeJS), you can use things like https://www.webjars.org. However, I would recommend to use NPM.
I am currently making a project that needs the JavaScript library typed.js but am also using the free webhost 000webhost which does not allow the use of Node.js. However, typed.js is installed using Yarn, NPM, or Bower, which to my knowledge needs Node.js.
Because of this, I would like to know how to install typed.js or have an alternative that is easy-to-use for someone who doesn't know much JavaScript.
Thanks.
Yeah its easy, download the library in zip format, goto /lib/ and find typed.min.js.
include this file as normal javascript file in your html
<script src="typed.min.js"></script>
Enjoy! all the functionalities. :)