I am trying to get myself started with Chart.js on statamic (with Laravel Herd), currently trying to run their step-by-step guide to no avail.
I did:
- Create a site locally (which works).
npm install chart.js
- Uncommented/added rows in the
vite.config.js
file as per the help. What I get is:import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin'; import vue2 from '@vitejs/plugin-vue2'; export default defineConfig({ plugins: [ laravel({ input: [ 'resources/css/site.css', 'resources/js/site.js', 'node_modules/chart.js/dist/chart.js', 'node_modules/chart.js/auto/auto.js' ], refresh: true, }), vue2(), ], });
npm run dev
After that, on Chrome and Firefox, I get an error Uncaught TypeError: Failed to resolve module specifier "chart.js/auto". Relative references must start with either "/", "./", or "../".
.
When I change the line import Chart from 'chart.js/auto';
as per the above, the error becomes:GET [...]chart.js/auto net::ERR_ABORTED 404 (Not Found)
- What is the correct relative or absolute URL to reach the JS module?
- More generally speaking, is there a way to check the mapping between the file system and the URL a resource will be provided through?
When talking about a page to be rendered, there is a field in the control panel of statamic but for that sort of external resource, I am lost.