1

我有未來的WebPack 2個規則配置時運行的WebPack扔了一個錯誤:的WebPack 2青菜裝載機意外的字符「@」

Unexpected character '@' (1:0) 
You may need an appropriate loader to handle this file type. 
| @media screen and (min-width: 40em) { 
| .feature { 
|  margin-bottom: 8.75rem; 
@ ./~/style-loader?{"camelCase":true,"localIdentName":"[name]_[local]_[hash:base64:3]","modules":true}!./~/postcss-loader!./~/resolve-url-loader!./~/sass-loader?{"sourceMap":true,"outputStyle":"expanded","include":["/opt/inmoblex/current/inmoblex/cfg/src/styles","node_modules"]}!./src/components/LandingFeature/styles.scss 4:14-310 

¿什麼是錯的?

:)

感謝您的幫助

rules: [ 
    { 
    test: /\.css$/, 
    use: [ 
     { loader: 'isomorphic-style-loader' }, 
     { loader: 'css-loader' }, 
     { loader: 'postcss-loader' }, 
    ] 
    }, 
    { 
    test: /\.scss/, 
    use: [ 
     { loader: 'isomorphic-style-loader' }, 
     { 
     loader: 'style-loader', 
     options: { 
      camelCase: true, 
      localIdentName: '[name]_[local]_[hash:base64:3]', 
      modules: true 
     } 
     }, 
     { loader: 'postcss-loader' }, 
     { loader: 'resolve-url-loader' }, 
     { 
     loader: 'sass-loader', 
     options: { 
      sourceMap: true, 
      outputStyle: 'expanded', 
      include: [ 
      path.resolve(__dirname, "./src/styles"), 
      "node_modules", 
      ], 
     } 
     }, 
    ] 
    }, 
    { 
    test: /\.json/, 
    use: [ 
     { loader: 'json-loader' }, 
    ] 
    }, 
    { 
    test: /\.(png|jpg|gif|woff|woff2)$/, 
    use: [{ 
     loader: 'url-loader', 
    }] 
    }, 
    { 
    test: /\.(mp4|ogg|svg)$/, 
    use: [{ 
     loader: 'file-loader', 
    }] 
    }, 
], 

回答

4

你的.scss後使用style-loader已被處理與sass-loaderresolve-url-loaderpostcss-loader。這樣的結果仍然是CSS,所以應該有一個css-loader將它轉換爲JavaScript。由於您使用的是isomorphic-style-loader,因此您不需要style-loader以及您傳遞給它的選項,看起來應該是css-loader。因此將style-loader重命名爲css-loader

{ 
    test: /\.scss/, 
    use: [ 
    { loader: 'isomorphic-style-loader' }, 
    { 
     loader: 'css-loader', 
     options: { 
     camelCase: true, 
     localIdentName: '[name]_[local]_[hash:base64:3]', 
     modules: true 
     } 
    }, 
    { loader: 'postcss-loader' }, 
    { loader: 'resolve-url-loader' }, 
    { 
     loader: 'sass-loader', 
     options: { 
     sourceMap: true, 
     outputStyle: 'expanded', 
     include: [ 
      path.resolve(__dirname, "./src/styles"), 
      "node_modules", 
     ], 
     } 
    }, 
    ] 
}, 
相關問題