减少在webpack中导入uikit

时间:2019-03-03 11:34:56

标签: webpack uikit

我正在尝试将uikit与webpack一起使用。 uikit的文档说:

  

注意出于简单性原因,我们包含了预构建的CSS。在一个   真正的项目,您可能要构建Less文件并包含   而是编译后的CSS。

因此,我正在尝试使用较少加载程序来执行此操作。但是出现此错误:


ERROR in ./src/index.js 1:0
Module parse failed: Unexpected character '@' (1:0)
You may need an appropriate loader to handle this file type.
> @import '~uikit/src/less/uikit';
| import m from 'mithril'
| import UIkit from 'uikit';
ℹ 「wdm」: Failed to compile.
^C
➜  npm git:(npm) ✗ cat webpack.config.js
var path = require('path');

module.exports = {
  mode: 'development',
  module: {
    rules: [
      {
        test: /\.css$/,
        loaders: ['style-loader', 'css-loader']
      },
      {
        test: /\.less$/,
        use: [{
          loader: 'style-loader'
        }, {
          loader: 'css-loader'
        }, {
          loader: 'less-loader'
        }]
      }
    ]
  }
};
➜  npm git:(npm) ✗ cat src/index.js
@import '~uikit/src/less/uikit';
import m from 'mithril'
import UIkit from 'uikit';
import Icons from 'uikit/dist/js/uikit-icons';

m.render(document.body, "hello world");
UIkit.use(Icons);
UIkit.notification('hello');

0 个答案:

没有答案