webpack 2 exits with code 3221226505 when importing external css (in vue.js component)

1.5k views Asked by At

I'm trying to use Google's Material Components for Web in my project. The problem is that when I'm adding the import statement, webpack doesn't output anything but exits with code 3221226505, according to npm.

Here's a snippet of my App.vue:

import 'material-components-web/dist/material-components-web.min.css';

The project's commit tree can be found here, and here's the npm log in case it contains anything interesting.

I hope someone can help me with this issue. If you find anything else unconventional in my repo, please let me know. Thank you!

2

There are 2 answers

0
sk22 On BEST ANSWER

Turned out I just forgot to define a loader for css files. Even though I'm still wondering why webpack just exits with some error code...

However, here's a part of my updated webpack.config.js. module.exports.module.rules does now contain this:

{
  test: /\.css$/,
  use: ['style-loader', 'css-loader']
}
2
Saurabh On

The syntax you are using to import css is wrong, it should be like following in your index.html as is given in the documentation:

 <link rel="stylesheet"
          href="node_modules/material-components-web/dist/material-components-web.css">

But node_modules will not be accessible as you are using webpack, you can move this file to your static folder and import it like following:

<link rel="stylesheet" href="/static/material-components-web.css" type="text/css">

Following is complete code from documentation:

<!DOCTYPE html>
<html class="mdc-typography">
  <head>
    <title>Material Components for the web</title>
    <link rel="stylesheet" href="/static/material-components-web.css" type="text/css">
  </head>
  <body>
    //HTML where you use material components
    <script src="/static/material-components-web.js"></script>
    <script>mdc.autoInit()</script>
  </body>
</html>