admin管理员组

文章数量:1122846

New to using laravel and vite.

Just trying to include DataTables in it.

So I created a new laravel project.

I added this to package.json

"jquery": "^3.7.1",
"datatables": "^2.0.8",

I added this to app.js

import jQuery from "jquery";
import $ from "jquery";

import DataTable from 'datatables';
window.DataTable = DataTable;

I add this to app.css

@import 'datatables';

Then I

  • npm install
  • opened a terminal and started Vite
  • opened another terminal and started Laravel
  • went to localhost:8000

and receive this error

[plugin:vite:css] [postcss] postcss-import: 

C:\Dev\repos\warp9time_website\node_modules\datatables\js\dataTables.js:23:1: Unclosed bracket
C:\Dev\repos\warp9time_website\node_modules\datatables\js\dataTables.js:23:0
21 |   */
22 |  
23 |  (function( factory ) {
   |  ^
24 |    "use strict";
25 |
    at Input.error (C:\Dev\repos\warp9time_website\node_modules\postcss\lib\input.js:106:16)
    at Parser.unclosedBracket (C:\Dev\repos\warp9time_website\node_modules\postcss\lib\parser.js:577:22)
    at Parser.other (C:\Dev\repos\warp9time_website\node_modules\postcss\lib\parser.js:423:35)
    at Parser.parse (C:\Dev\repos\warp9time_website\node_modules\postcss\lib\parser.js:470:16)
    at parse (C:\Dev\repos\warp9time_website\node_modules\postcss\lib\parse.js:11:12)
    at get root [as root] (C:\Dev\repos\warp9time_website\node_modules\postcss\lib\no-work-result.js:119:14)
    at Result.get [as root] (C:\Dev\repos\warp9time_website\node_modules\postcss\lib\no-work-result.js:27:21)
    at loadImportContent (file:///C:/Dev/repos/warp9time_website/node_modules/vite/dist/node/chunks/dep-C6EFp3uH.js:867:33)
    at async Promise.all (index 0)
    at async resolveImportId (file:///C:/Dev/repos/warp9time_website/node_modules/vite/dist/node/chunks/dep-C6EFp3uH.js:800:27

A side note I have tried the various solutions in the post and they didn't work either.

How to use DataTables with Laravel Vite?

本文标签: Laravel Postcss Vite Datatablesnet 0 unenclosed bracket errorStack Overflow