Skip to content

unexpected '!' in '!!file-loader?name=sql-wasm-[contenthash].wasm!sql.js/dist/sql-wasm.wasm'. do not use import syntax to configure webpack loaders #7

@Jansora

Description

@Jansora

When i using craco replace creact-react-app built the react app.
package.json

    "react-scripts": "4.0.3",
    "sql.js": "^1.6.0",
    "devDependencies": {
      "@craco/craco": "^6.2.0",
      "craco-less": "^1.20.0"
    },

SqlJsDemo.jsx

import initSqlJs from "sql.js";
// Required to let webpack 4 know it needs to copy the wasm file to our assets
// import sqlWasm from "!!file-loader?name=sql-wasm-[contenthash].wasm!sql.js/dist/sql-wasm.wasm";

  const [db, setDb] = useState(null)
  useEffect( () => {
    if(db == null) {
      initSqlJs(
        {
          locateFile: sqlWasm
        }
      )
        .then(SQL => setDb(new SQL.Database()))
        .catch(err => console.error(err) || Message.error("init sqlite failed"));
    }
  }, [db])

when i run cacro start, i got this error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions