Summary of Usage methods for Extract-text-webpack-plugin plugins in Webpack

Source: Internet
Author: User

Why use Extract-text-webpack-plugin this plugin, this plug-in can be implemented for our style modular, and in the packaging of the time can generate a always CSS file. I used it in the React project. What's the next use?

1, first we NPM installs NPM install Extract-text-webpack-plugin--save-dev.

2, configuration in webpack.config.js first we are going to introduce

Const EXTRACTTEXTWEBPACK = require ("Extract-text-webpack-plugin"); A detailed description of the inside parameters can be seen on the GIT website https://github.com/webpack-contrib/extract-text-webpack-plugin
    Module: {        loaders: [            {                test:/\.js (x)? $/,                loader: "Babel-loader",                Exclude:/mode_modules/            } ,            {                test:/\.css$/,                extracttextwebpack.extract ({                    fallback: ' Style-loader ', use                    : [' Css-loader '],                    publicPath:path.resolve (__dirname, ' dist ')}}        ]    }

3: We want to see this folder after compiling, this will generate a style.css in our dist directory, if you use less. Sass,stylus this time you just need to download the corresponding loader and then make the corresponding configuration in the inside.

plugins: [        new  htmlwebpackplugin ({            './src/index.html ')        }),         New Extracttextwebpack ("Style.css")    ]

Summary of Usage methods for Extract-text-webpack-plugin plugins in Webpack

Related Article

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.