Webpack react individually packaged CSS

Source: Internet
Author: User

Webpack react individually packaged CSS

Webpack require CSS method, the default will be the CSS into the JS file, loading sequence is problematic, if you need to play a separate CSS file

Operation Steps: Step1:

Installing the Webpack plugin plugin

npm install extract-text-webpack-plugin --save

Step2:

Modifying the Webpack.config.js configuration

Reference Plugin

var ExtractTextPlugin = require("extract-text-webpack-plugin");

In the module of config:

{test:/\.less$/, Loader:ExtractTextPlugin.extract ("Style-loader", "Css-loader", "Less-loader")},  

Last plugins add

Problem

Q:Module build failed: ReferenceError: window is not defined.

A: Modify Loader

error demonstration:  loader:extracttextplugin.extract ("Style-loader!css-loader!less-loader")

Correct demonstration:loader: ExtractTextPlugin.extract("style-loader", "css-loader","less-loader")

Reference article:

1. https://webpack.github.io/docs/stylesheets.html

2. Http://stackoverflow.com/questions/28223040/window-not-defined-error-when-using-extract-text-webpack-plugin-react

Webpack react individually packaged CSS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.