lets say I have a huge js file with global functions like:
function a() ....
function b() ....
How can I import them to a webpack bundle and use? require/import?
lets say I have a huge js file with global functions like:
function a() ....
function b() ....
How can I import them to a webpack bundle and use? require/import?
The simple way to add your function to webpack is:
1) create new js file in assets for example assets/js/fnc.js is our file name.
2) Import fnc.js to app for example I use the vue.
import Vue from 'vue'
...
import Fnc from '@/assets/js/fnc.js';
import HelloWorld from '@/components/HelloWorld'
...
Then you can use your functions : )
Note: define functions by this pattern:
a = function () { alert(1); return false; } b = function () { alert(2); return false; }Don't define with your pattern and don't use
varorletbefore function name.