LoginSignup
0
0

More than 5 years have passed since last update.

Troubleshooting in Vue2 Element UI with Webpack4

Last updated at Posted at 2018-07-12

Error 1.

ERROR in ./node_modules/element-ui/lib/theme-chalk/index.css 1:0
Module parse failed: Unexpected character '@' (1:0)
You may need an appropriate loader to handle this file type.

Solution 1.

$ yarn add -D style-loader
  module: {
    rules: [
      ...
      {
        test: /\.(sa|sc|c)ss$/,
        include: [
          path.resolve('src'),
          path.resolve('node_modules/element-ui/'), <-- If you use webpack include rule, add this.
        ],
        use: [
          'vue-style-loader',
          'style-loader',  <-- Add this.
          'css-loader',
        ],
      },
      ...
    ],
  },

Error 2.

ERROR in ./node_modules/element-ui/lib/theme-chalk/fonts/element-icons.ttf 1:0
Module parse failed: Unexpected character ' ' (1:0)
You may need an appropriate loader to handle this file type.
...
...
...
ERROR in ./node_modules/element-ui/lib/theme-chalk/fonts/element-icons.woff 1:4
Module parse failed: Unexpected character ' ' (1:4)
You may need an appropriate loader to handle this file type.

Solution 2.

$ yarn add -D file-loader
  module: {
    rules: [
      ...
      {
        test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)(\?.+)?$/, <-- Add this.
        include: [
          path.resolve('src'),
          path.resolve('node_modules/element-ui/'), <-- If you use webpack include rule, add this.
        ],
        use: [
          {
            loader: 'url-loader',
            options: {
              limit: 10000,
            },
          },
        ],
      },
      ...
    ],
  },
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0