webpack-style-loader

Webpack bundle all css and load first

﹥>﹥吖頭↗ 提交于 2020-01-04 05:28:36
问题 How to bundle all the css file together and load on the top of the head before the document loads using webpack ? 回答1: From my understanding, using a dummy .js file in order just to build a global/shared css bundle which imports needed css files may be a solution. I don't know if this is a best practice but works for me. An alternative approach may bu using Webpack together with Gulp, but it means an extra step will be required in every build. So in webpack.config.js I have an entry such as:

'window is not defined' error when using style-loader with webpack

∥☆過路亽.° 提交于 2020-01-02 01:15:13
问题 Building a server side react app and while using Webpack I am having issues with Style-Loader. I am using version "^0.23.1" and when running a script to bundle and build there is an issue from Style-Loader. The issue is window is not defined webpack:///./node_modules/style-loader/lib/addStyles.js?:23 return window && document && document.all && !window.atob; Has anyone run into this issue? After looking through Stack and the Github issues for style-loader I am not finding any solution. Here

import CSS and JS files using Webpack

百般思念 提交于 2019-12-30 04:05:13
问题 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, '../..

Chrome Debugger - “No Domain” Section Showing Duplicated Paths (after Webpack)

≡放荡痞女 提交于 2019-12-24 11:29:24
问题 I will first include a picture, as it explains the situation the best: My question is as follows: The paths circled in red are really odd. Here is an example: C:/Users/..../Documents/Programming/_actual-programs/html-css-js/github-pages/name.github.io/src/C:/Users/.../Documents/Programming/_actual-programs/html-css-js/github-pages/name.github.io/src/C:/Users/.../Documents/Programming/_actual-programs/html-css-js/github-pages/name.github.io/src/C:/Users/.../Documents/Programming/_actual

Webpack not loading background image

喜夏-厌秋 提交于 2019-12-23 18:31:03
问题 I am trying to load a image: background: transparent url("../img/select-icon.png") no-repeat center right 8px; At my style.scss and it is not working Here is my webpack.config: function _path(p) { return path.join(__dirname, p); } module.exports = { context: __dirname, entry: [ './assets/js/index' ], output: { path: path.resolve('./assets/bundles/'), filename: '[name].js' }, devtool: 'inline-eval-cheap-source-map', plugins: [ new BundleTracker({filename: './webpack-stats.json'}), new webpack

Webpack loading CSS into individual <style> tags

半世苍凉 提交于 2019-12-23 15:46:13
问题 I'm currently using the below Webpack config to import and parse the SCSS imports I make in my React components. The crux of my issue is with the CSS part of the config. Currently, I'm importing SCSS files using their absolute file paths in their relevant React components. However on render, each individual CSS import gets their own <style> tag which results in a dozen <style> tags littered in the head of my web app. Is there a way to tweak the config such that the outputted CSS goes into one

Webpack Uglify errors in CSS

亡梦爱人 提交于 2019-12-23 07:34:42
问题 Im stressed trying to make Uglify working with my project, previously I have used Uglify and was not giving problems but now I think that is SASS related. ERROR in ./~/css-loader!./~/sass-loader!./app/scss/global-header.scss Module build failed: TypeError: Cannot read property '4' of undefined at reduce (/Users/contractor/centralefcom-global-components/node_modules/postcss-reduce-transforms/dist/index.js:121:23) at walk (/Users/contractor/centralefcom-global-components/node_modules/postcss

Webpack Uglify errors in CSS

﹥>﹥吖頭↗ 提交于 2019-12-23 07:34:06
问题 Im stressed trying to make Uglify working with my project, previously I have used Uglify and was not giving problems but now I think that is SASS related. ERROR in ./~/css-loader!./~/sass-loader!./app/scss/global-header.scss Module build failed: TypeError: Cannot read property '4' of undefined at reduce (/Users/contractor/centralefcom-global-components/node_modules/postcss-reduce-transforms/dist/index.js:121:23) at walk (/Users/contractor/centralefcom-global-components/node_modules/postcss

Webpack + React + Loading CSS of external modules

大兔子大兔子 提交于 2019-12-22 13:33:14
问题 Webpack/CSS Experts! My NodeJS/React application has the following structure, where I use Webpack 3.8.1 to package & bundle files. -app |--actions |--constants |--components |--containers |--css |--reducers |--store -common -server -webpack |--rules |--css |--javascript |--externals |--paths |--resolve |--webpack.config.js Everything works as expected in development and production but there is one problem that I have been struggling with: External node modules CSS . When I add a new

Angular2/Webpack: how to load fonts that are imported inside css files?

[亡魂溺海] 提交于 2019-12-22 11:13:10
问题 I'm using Angular2 beta.15 and webpack 1.12.14. I have one .css and one .scss file in app.component.ts as global patterns like this. @Component({ selector: 'my-app', templateUrl: 'app/app.component.html', styles: [ require('../stylesheets/css/main.min.css'), require('../sass/example.scss') ], encapsulation: ViewEncapsulation.None, }) And, inside .css file, some fonts are imported like below, @font-face { font-family: 'Helvetica Neue'; src: url(fonts/light/helvetica-neue-light.eot) format("eot