Vue 3 include local static files into index.html

2.5k Views Asked by At
<!DOCTYPE html>
<html lang="">
  <head>
    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
    <title><%= htmlWebpackPlugin.options.title %></title>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
    <link rel="stylesheet" href="semantic/dist/semantic.min.css">

I have a basic Vue 3 project and within my public/index.html file I want to include files from root directory (e.g. node_modules or my semantic folder)

I've tried various configurations within vue.config.js file but seems like none of them works.

module.exports = {
  publicPath: '',
}

What's the proper way of including custom local css/js files into index.hmtl without moving them directly into public directory?

1

There are 1 best solutions below

0
On

I was with a similar problem a time ago, I asked here too but I found the solution myself, here is the link, how I was using my own webpack configuration, it may differ from what you need to do, but I think the core is the same, the esModule option on file-loader was messing with the path of local files I wanted to load.