Vue.js CLI and Papaparse for CSVs
I am working on a side project for work and decided to move the proof-of-concept to Vue.js. After several weeks of spinning up on the Vue framework and Webpack, I've started implementing. Issue #1: Can't use <script> tag to load Papa Parse in Webpack In the original project I used Papa Parse to parse CSVs by including it with a <script> tag. In Vue CLI, it's a bit more involved. You need a file loader (Webpack's csv-loader in this case), which runs Papa Parse for you (after you configure vue.config.js to use the Webpack loader via chainWebpack ). So you can do something like this in your main.js file: import Papa from "@/assets/data/mycsv.csv"; Which loaded the file as JSON as desired; however, I needed to dynamically load CSVs depending on a user selection. Issue #2: Conditionally loading CSVs After several frustrating hours, I discovered the dynamic import() feature of JavaScript which allows you to load modules conditionally at...