Electron-Webpack无法编译photonkit

时间:2018-03-02 12:19:30

标签: webpack electron

我的index.js文件有一个import './index.css'语句,而index.css目前只有@import 'photonkit/dist/css/photon.css'

的package.json

{
  "name": "electron-webpack-quick-start",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "dev": "electron-webpack dev",
    "compile": "electron-webpack",
    "dist": "yarn compile && electron-builder --win portable",
    "dist:dir": "yarn dist --dir -c.compression=store -c.mac.identity=null"
  },
  "dependencies": {
    "axios": "^0.18.0",
    "electron-cookies": "^1.1.0",
    "photonkit": "^0.1.2",
    "source-map-support": "^0.5.3",
    "vue": "^2.5.13",
    "vue-router": "^3.0.1"
  },
  "devDependencies": {
    "autoprefixer": "^8.0.0",
    "css-loader": "^0.28.10",
    "electron": "1.8.2",
    "electron-builder": "^20.0.6",
    "electron-webpack": "^1.13.0",
    "file-loader": "^1.1.10",
    "node-sass": "^4.7.2",
    "postcss-loader": "^2.1.1",
    "sass-loader": "^6.0.6",
    "style-loader": "^0.20.2",
    "vue-loader": "^14.1.1",
    "vue-template-compiler": "^2.5.13",
    "webpack": "^3.11.0"
  },
  "resolutions": {
    "webpack-sources": "1.0.1"
  },
  "electronWebpack": {
    "renderer": {
      "webpackConfig": "webpack.additions.js"
    },
  }
}

如您所见,我从webpack.additions.js加载了包含以下内容的其他webpack配置:

module.exports = {
    module: {
        rules: [
            {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          loaders: {
           'sass': 'vue-style-loader!css-loader!sass-loader?indented-syntax',
          }
        }
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: '/node_modules/'
      },
      {
        test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif|svg)$/,
        loader: 'file-loader',
        options: {
          name: '[name].[ext]?[hash]'
        }
      },
      {
       test: /\.s?css$/,
       exclude: '/node_modules/',
       use: [
         {
           loader: 'sass-loader'
         },
         {
           loader: 'style-loader'
         },
         {
           loader: 'css-loader'
         },
         {
           loader: 'postcss-loader',
           options: {
             plugins: function(){
               return [require('autoprefixer')];
             }
           }
         },
       ]
      },
        ]
    }
}

webpack无法编译在photonkit import语句中抛出错误:

@import 'photonkit/dist/css/photon.css'
  ^
        Invalid CSS after "": expected 1 selector or at-rule, was "var content = requi"

当我尝试通过'phontonkit/scss/photon.scss'

加载scss版本时也会发生同样的情况

它似乎不是装载机问题。有人能给我一些线索吗?

0 个答案:

没有答案