webpack-style-loader

How can I use style-loader in react SSR (Server Side Rendering)?

泄露秘密 提交于 2019-12-01 18:42:03
问题 As you know, we can easily use style-loader to add our styles to our react project, but the window is not available in Server Side Rendering, so how I can use style-loader (or something instead of that in SSR project)? When I use style-loader , it returns this error as expected: .../public/server.js:866 return window && document && document.all && !window.atob; ^ ReferenceError: window is not defined 回答1: I just found an answer to my question; We can use isomorphic-style-loader for loading

Webpack + Firebase: Disable parsing of Firebase

感情迁移 提交于 2019-11-30 22:31:43
I am working on a web app that uses Webpack to bundle modules. For whatever reason, the introduction of Firebase into the app is causing Webpack to throw an error. This error is occurring when Webpack attempts to load the Firebase module. How do I go about excluding Firebase from Webpack, but can still call import Firebase from 'firebase'; from within my JS files? Here are some screenshots of the error. pic1 pic2 tl;dr Exclude /node_modules/ from the babel-loader paths. Your 2nd pic shows the error on firebase-web.js:12 : Uncaught TypeError: Cannot read property 'navigator' of undefined

import CSS and JS files using Webpack

岁酱吖の 提交于 2019-11-30 12:22:10
I have a directory structure like this: and inside node_modules: >node_modules >./bin >webpack.config.js >bootstrap >bootstrap.css >bootstrap.js I need to generate separate CSS and JS bundles like this: custom-styles.css, custom-js.js, style-libs.css, js-libs.js where style-libs and js-libs should contain syles and js files of all libraries like bootstrap and jQuery. Here's what I have done so far: webpack.config.js: const path = require('path'); const basedir = path.join(__dirname, '../../client'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const stylesPath = path.join(_

Why am I not being able to compile SASS with Webpack?

杀马特。学长 韩版系。学妹 提交于 2019-11-30 03:27:36
I have the following modules in my Webpack config: module: { preLoaders: [ { test: /\.vue$/, loader: 'eslint', include: projectRoot, exclude: /node_modules/ }, { test: /\.js$/, loader: 'eslint', include: projectRoot, exclude: /node_modules/ } ], loaders: [ { test: /\.vue$/, loader: 'vue' }, { test: /\.js$/, loader: 'babel', include: projectRoot, exclude: /node_modules/ }, { test: /\.json$/, loader: 'json' }, { test: /\.html$/, loader: 'vue-html' }, { test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, loader: 'url', query: { limit: 10000, name: utils.assetsPath('img/[name].[hash:7].[ext]') } }, { test: /\

React Server side rendering of CSS modules

岁酱吖の 提交于 2019-11-30 00:04:23
The current practice for CSS with React components seems to be using webpack's style-loader to load it into the page in. import React, { Component } from 'react'; import style from './style.css'; class MyComponent extends Component { render(){ return ( <div className={style.demo}>Hello world!</div> ); } } By doing this the style-loader will inject a <style> element into the DOM. However, the <style> will not be in the virtual DOM and so if doing server side rendering, the <style> will be omitted. This cause the page to have FOUC . Is there any other methods to load CSS modules that work on

Error: Cannot resolve module 'style-loader'

浪尽此生 提交于 2019-11-29 23:28:02
I'm using style-loader with webpack and react framework. When I run webpack in terminal i'm getting Module not found: Error: Cannot resolve module 'style-loader' in import.js file although i've specified the file path correctly. import '../css/style.css'; import React from 'react'; import ReactDOM from 'react-dom'; import jQuery from 'jquery'; import TopicsList from '../components/topic-list.jsx'; import Layout from '../components/layout.jsx'; webpack.config.js: var webpack = require('webpack'); var path = require('path'); var BUILD_DIR = path.resolve(__dirname, 'build'); var APP_DIR = path

Import CSS from “node_modules” in Webpack

给你一囗甜甜゛ 提交于 2019-11-29 10:53:16
问题 Some third-party modules I'm using have their own CSS files. I'd like to include them in my app's one, single CSS file, which is processed by Webpack. How can CSS files under "node_modules" be imported into my CSS file? For example, I'm using the third-party react-select module, but I can't import its CSS file from node_modules : @import 'react-select/dist/react-datetime.css'; The relevant loader in webpack.config.js : { test: /\.css$/, use: ExtractTextPlugin.extract({ use: [ { loader: 'css

Webpack 2: WARNING in .png, .svg, .. DEPRECATED. Configure optipng's optimizationLevel option in it's own options. (optipng.optimizationLevel)

跟風遠走 提交于 2019-11-29 10:16:44
This WARNING is printed ~20 times when running webpack - it processes and bundles just fine, but what does it mean? How do I get rid of it? Googling around provides little to no help unfortunately. Here's my webpack config: const ExtractTextPlugin = require("extract-text-webpack-plugin"); var webpack = require("webpack"); module.exports = { entry: { dashboard: './js/main.js', vendor: ["fixed-data-table","react","react-dom","jquery", "bootstrap", "vis",], }, output: { path: "../public", filename: 'bundle.js' }, plugins: [ new webpack.optimize.CommonsChunkPlugin({name: "vendor", filename:

Why am I not being able to compile SASS with Webpack?

独自空忆成欢 提交于 2019-11-29 00:08:29
问题 I have the following modules in my Webpack config: module: { preLoaders: [ { test: /\.vue$/, loader: 'eslint', include: projectRoot, exclude: /node_modules/ }, { test: /\.js$/, loader: 'eslint', include: projectRoot, exclude: /node_modules/ } ], loaders: [ { test: /\.vue$/, loader: 'vue' }, { test: /\.js$/, loader: 'babel', include: projectRoot, exclude: /node_modules/ }, { test: /\.json$/, loader: 'json' }, { test: /\.html$/, loader: 'vue-html' }, { test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,

Error: Cannot resolve module 'style-loader'

痴心易碎 提交于 2019-11-28 21:20:49
问题 I'm using style-loader with webpack and react framework. When I run webpack in terminal i'm getting Module not found: Error: Cannot resolve module 'style-loader' in import.js file although i've specified the file path correctly. import '../css/style.css'; import React from 'react'; import ReactDOM from 'react-dom'; import jQuery from 'jquery'; import TopicsList from '../components/topic-list.jsx'; import Layout from '../components/layout.jsx'; webpack.config.js: var webpack = require('webpack