无法使用import解析.jsx中的.scss文件

时间:2017-02-17 22:25:11

标签: node.js reactjs webpack react-jsx webpack-dev-server

当我尝试构建我的反应应用时,我收到了错误消息。

componentDidMount() { var self = this; getProjectName() .then(val => { self.setState({relatedTo: val}); }); }

webpack-dev-server --progress --inline --watch

我使用ERROR in ./app/index.jsx Module not found: Error: Can't resolve 'styles/main' in '/Users/jono/dev/recipist/app' @ ./app/index.jsx 11:12-34 @ multi (webpack)-dev-server/client?http://localhost:8080 ./app/index.jsx

导入 index.jsx

这就是我树的样子:

import style from 'styles/main';

webpack.config.js https://github.com/jonofan/recipist/blob/master/webpack.config.js

我也尝试过在不使用配置中的解析扩展程序的情况下引用完整扩展程序,但同样的问题。

2 个答案:

答案 0 :(得分:1)

根据配置方式,它没有指向正确的文件路径。

使用import style from './styles/main.scss'代替

还要确保您已经通过npm安装了css-loader sass-loaderstyle-loader并保存到您的package.json

答案 1 :(得分:0)

要解决此问题,您应该将 css-loader <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://rawgit.com/kangax/fabric.js/master/dist/fabric.js"></script> <canvas id="c" width="300" height="300"></canvas> <button id="addAsGroup">AddAsGroup</button> <button id="addAsSeparateObjects">AddAsSeparateObjects</button>选项更改为 public static String callTestService(String soapRequestXml, String url) { try{ final boolean isHttps = url.toLowerCase().startsWith("https"); HttpsURLConnection httpsConnection = null; // Open HTTPS connection // Create a trust manager that does not validate certificate chains TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted(X509Certificate[] certs, String authType) { } public void checkServerTrusted(X509Certificate[] certs, String authType) { } } }; if (isHttps) { // Create SSL context and trust all certificates SSLContext sslContext = SSLContext.getInstance("SSL"); //TrustManager[] trustAll= new TrustManager[] {new TrustAllCertificates()}; sslContext.init(null, trustAllCerts, new java.security.SecureRandom()); // Set trust all certificates context to HttpsURLConnection HttpsURLConnection .setDefaultSSLSocketFactory(sslContext.getSocketFactory()); // Open HTTPS connection // URL url1 = new URL(url); URL url1 = new URL(null, url, new sun.net.www.protocol.https.Handler()); httpsConnection = (HttpsURLConnection) url1.openConnection(); // Trust all hosts // httpsConnection.setHostnameVerifier(new TrustAllHosts()); // Connect //Use below (2 lines) if Host name verification needs to turned off MyHostnameVerifier HostVerifier = new MyHostnameVerifier(); httpsConnection.setHostnameVerifier(HostVerifier); httpsConnection.connect(); } // Create SOAP Connection SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection soapConnection = soapConnectionFactory.createConnection(); System.out.println("create connection"); // SOAPMessage soapRequest = MessageFactory.newInstance().createMessage(new MimeHeaders(), // new ByteArrayInputStream(soapRequestXml.getBytes())); SOAPMessage soapRequest = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL).createMessage(new MimeHeaders() , new ByteArrayInputStream(soapRequestXml.getBytes(Charset.forName("UTF-8")))); // SOAPMessage s = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); // SOAPPart soapPart = soapRequest.getSOAPPart(); // SOAP Envelope // SOAPEnvelope envelope = soapPart.getEnvelope(); // envelope.addNamespaceDeclaration("Dokumentai", "http://vmi.lt/ais/xsd/daa"); // MessageFactory messageFactory = MessageFactory.newInstance(); //SOAPMessage soapRequest = messageFactory.createMessage(new MimeHeaders(),soapRequestXml); // MessageFactory messageFactory = MessageFactory.newInstance(); // SOAPMessage soapRequest = messageFactory.createMessage(); // SOAPPart soapPart = soapRequest.getSOAPPart(); // SOAPEnvelope envelope = soapPart.getEnvelope(); // SOAPBody soapBody = envelope.getBody(); //soapBody.setTextContent(soapRequestXml); // soapRequest.setContentDescription(soapRequestXml); // SOAPPart soapPart = soapRequest.getSOAPPart(); //SOAPEnvelope envelope = soapPart.getEnvelope(); // String serverURI = "myhost"; // envelope.addNamespaceDeclaration("xmlns", // "http://vmi.lt/ais/xsd/daa"); // SOAP Envelope // SOAPEnvelope envelope = soapPart.setContent(soapRequestXml); // System.out.println("SOAP "+ soapRequest.writeTo(System.out)); MimeHeaders headers = soapRequest.getMimeHeaders(); headers.setHeader("SOAPAction", "http://vmi.lt/ais/ws/handleMessage"); MimeHeaders headers1 = soapRequest.getMimeHeaders(); headers1.setHeader("Content-Type", "application/soap+xml; charset=utf-8"); soapRequest.saveChanges(); soapRequest.writeTo(System.out); System.out.println("call request url"); // Send SOAP Message to SOAP Server SOAPMessage soapResponse = soapConnection.call(soapRequest, url); soapResponse.setProperty("Content-Type", "application/xml; charset=utf-8"); soapResponse.setContentDescription("application/xml; charset=utf-8"); ByteArrayOutputStream soapResponseBaos = new ByteArrayOutputStream(); soapResponse.writeTo(soapResponseBaos); String soapResponseXml = soapResponseBaos.toString(); return soapResponseXml; }catch(Exception e){ return e.toString(); } }

modules