[Vuejs]-Import static .js in Vue-cli + webpack

0👍

If I understand well your project arch is like

/root
  |__/public
  |     |__/img
  |     |__/css
  |     |__/constants
  |            |__/foo.js
  |            |__/bar.js
  |__/webpack.config.js

In your webpack.config.js create a new entry like

module.exports = {
  entry: './public/index.js'
};

Then create a index.js file inside your public directory and import your foo.js

import foo from './constants/foo';

Of course your foo.js should export something like

export default function foo() {
  //
}

Hoping that will help you.

Leave a comment