So with the doc I was following that installs Node and Webpack, are you saying I can just release my app.ts and index.html? Do I have to install Node on the server?
Because I’m worried I need to upload all my node modules as well, (Don’t need all of them) and install other packages that I don’t want on the server.
Is there any way to build out just what I need as a static app?
If you’re using webpack, the server just needs to host your generated project bundle.js and required resources that you want to host, no ts files should be needed on the webserver.
So I’m assuming that you want a game that is hosted on a webserver that a user can access and play on their machine locally, right? Feel free to correct me if this isnt the case.
so, we have our build machine -> this machine uses webpack to compile the current game .ts code into a distributable .js bundle. This can be either your local dev machine, or an instance that does this via git hook. Webpack (or whatever bundling technology) is responsible for the final game package being generated here.
The webserver is what should be consuming this game package, and is responsible for serving it to users who want to access this. This can be done over FTP, or git hooks as well, depending on how you choose to host your output bundle. But at the end of the day, you need to be able to take your generated .js bundle and the rest of your project files/pages and get them onto your webserver to be hosted.
we configure webpack to inject our bundle into the index.html webpage, and to copy over all our consumed assets from our project public folder, and here in our tsconfig.json we tell webpack where to consume our source files from, where is our entry point, and where we should put our generated files post-build. (i use /dist as the build directory)
Currently I was able to build this locally on my computer, via npm run build and manually copied the contents from my generated /dist folder into the actual hosted project repo hosted courtesy of github.io:
These files can be placed can be wherever your webserver expects to find the files to host.
Yes basically this is what I’m looking for, I just don’t see any generated files when I run npm run build all I see is my solution files and no ‘output’ of distribution files:
So that’s what I’m a little confused about, is there supposed to be an output where my distribute package is? Because the only thing I can understand is I’m running it locally by a webpack build.
Does that get webpack to properly move the built bundle to /dist?
EDIT:
Also its important to note that in package.json we specify our entry point (i think? this is where my expertise gets a bit fuzzy, I’m not too sure what the difference between the declarations of main in package.json and entry in webpack.config.json specify specifically) @RaananW, can you clarify?:
Last question, I have my /dist Versioned as a git submodule, when I build the contents of the folder are being removed. Is there a way to skip the .git folder?
Also my setting is "outDir": "./dist/web_developersdeck_build/build/",
But when I run a npm build it’s pushing to the web_developersdeck@1.0.0 build D:\Development\Web\web_developersdeck
tsconfig - the configuration there will define where tsconfig’s base path is, and where it will output the compiled javascript files. If you use webpack (with the tsloader), there is no need to define the output directory, the tsloader will compile the files and will stream them further down the pipeline.
package.json - the main key is for people using your package. This defines the main entry file that will be used when you require the package. of course it gets a bit more complicated when you are using es6 imports, but that’s the basic gist.
webpack! fun fun fun. Webpack’s default output directory is the dist directory of your project. You are bundling all ts files to a single file in ./dist/js.
If you don’t want webpack to be in charge of the compilation, use tsc directly. it will be quicker! But you won’t have a bundle, and won’t have other features like optimization/minification, html injection and so on.
I am not quite sure about your last question - it feels like an over-complicated way of achieving deployment using git commits. If you use webpack, all you need is to deploy your dist folder. What you can do is use some form of a CI tool (there are many, and many are free for small projects), and use it to have your project built online somewhere and deployed to a webserver that supports static deployment. netlify.com is one of those places that does everything for you, there is also vercel.com and many others.
First, our chinese community members were complaining about the doc page speed in china. This is due to the fact that netlify doesn’t have an endpoint there. Second, I develped the doc page using next.js, and the native support for next.js on vercel is amazing (kind’a makes sense, since they created next.js).
I also like the way they deal with PR security.
We still use netlify, and we still love netlify, but we diverse constantly. The playground is using azure, website is using netlify, docs use vercel.