#ARMA 2 CONFIG FILE TWEAKS CODE#
The entry property tells webpack where our source code is located. Create a file called and place the following code inside it: const path = require('path')
Now that we have webpack installed and have gone through a quick sanity check exercise, let's create an actual webpack config file. Demo app output 2 - no changes Create a Webpack Config File Now, refresh the page in your browser, and you should still see the exact same output, only this time the "Hello from webpack!" text is being generated by the. Instead of the script tag looking like this: OK, now that we have JavaScript code in our dist directory, let's have our index.html file reference that. And inside it you should see a main.js file, which is our minified code. You should now see a dist directory created in your project directory. Now, for any real project you will need to do some configuration, but it's nice that you can at least do a quick sanity check to ensure that webpack is able to run without having to go through a bunch of initial configuration steps. Webpack 4 is set up as a "zero config" tool, meaning that you can run it out of the box without doing any initial configuration.
#ARMA 2 CONFIG FILE TWEAKS INSTALL#
To install those, run: yarn install Webpack Test Run I've included webpack and webpack-cli as devDependencies in the package.json file. If you drag the index.html file into your browser, you should be able to view our simple web page: Demo app output 1 - hello from webpack src/index.js file, which has just a few lines of JavaScript in it that outputs the text, "Hello from webpack!": const p = document.createElement('p') The index.html file is nice and simple, just a page header and a script tag: The directory structure looks like this: webpack-demo To begin, we'll start out with just a few files in our project directory. The starting point is found here, and the finished result is found here. If you'd like to follow along, all of the code in this article can be found in GitHub.
The actual app code will be pretty small so that we can focus more on webpack. Our app will just use vanilla JavaScript so that we don't get bogged down with any framework-specific details. Webpack bundles your codeįor the purposes of this demo, we'll be setting up a webpack config from scratch using webpack 4. We’ll discuss output management, asset management, dev and prod configs, Babel, minification, cache busting, and more. In this hands-on tutorial, we’ll go through the basics of setting up your very own production-ready webpack config using webpack 4. Because of this, many developers don’t have a lot of experience working with webpack. Typically, webpack is configured when a project is first set up, and small tweaks are then made to the config files as needed from time to time. Webpack is a powerful bundler and dependency manager used by many enterprise-level companies as tooling for their front-end code.