npm-windows-upgrade --npm-version latest
npm-windows-upgrade
tool as explained here.Pros:
Great for working with singe-page apps
Accepts both require() and import module syntaxes
Allows for very advanced code splitting
Hot Reload for quicker development with React, Vue.js and similar frameworks
Мost popular build tool according to the 2016 JavaScript survey
Cons:
Not suitable for beginners in web development
Working with CSS files, images, and other non-JS resources is confusing at first
Documentation could be better
Changes a lot, even most 2016 tutorials are already outdated
npm install webpack --save-dev
"scripts": { "build": "webpack -p", "watch": "webpack --watch" }, |
webpack.config.js
entry
option tells webpack which is our main JavaScript file.output
we specify the name and path of our bundle. After running webpack we will have all our JavaScript in a file called bundle.js
. This is the only script file that we will link in our HTML.export default functionName
;
import functionName from './path/to/function.js';
npm install libraryName --save
import libraryName from 'libraryName';
npm install loaderName --save-dev
npm run build
ERROR in ./src/main.js
Module build failed: Error: Failed to load plugin node: Cannot find module 'eslint-plugin-node'
npm install --save-dev eslint-plugin-node
Module build failed: SyntaxError: Unexpected token (
{# ... #}
). When I got rid of the code that was commented-out like that, the error message went away.