Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is ElementUI compatible with Webpack's ExtractTextPlugin? #33

Open
lucas-bremond opened this issue Jan 29, 2018 · 0 comments
Open

Is ElementUI compatible with Webpack's ExtractTextPlugin? #33

lucas-bremond opened this issue Jan 29, 2018 · 0 comments

Comments

@lucas-bremond
Copy link

lucas-bremond commented Jan 29, 2018

Hi!

In my main.ts file, I have:

import 'element-theme-default' ;

and in my webpack.config.prod.js:

const extractCss = new ExtractTextPlugin
(
    {
        filename: 'css/[name].[contenthash]-first.css',
        disable: process.env.NODE_ENV === 'development'
    }
) ;

const extractSass = new ExtractTextPlugin
(
    {
        filename: 'css/[name].[contenthash]-second.css',
        disable: process.env.NODE_ENV === 'development'
    }
) ;

webpackConfig.module.rules = 
[
    ...webpackConfig.module.rules,
    {
        test: /\.css$/,
        use: ExtractTextPlugin.extract
        (
            {
                use: ['css-loader'],
                fallback: 'style-loader'
            }
        )
    },
    {
        test: /\.*(sass|scss)$/,
        use: ExtractTextPlugin.extract
        (
            {
                use: ['css-loader', 'sass-loader'],
                fallback: 'style-loader'
            }
        )
    },
    {
        test: /\.(jpg|png|gif)$/,
        loader: 'file-loader?name=assets/img/[name].[ext]'
    },
    {
        test: /\.(eot|svg|ttf|woff|woff2)$/,
        loader: 'file-loader?name=fonts/[name].[ext]'
    }
] ;

webpackConfig.plugins =
[
    ...webpackConfig.plugins,
    new CommonsChunkPlugin
    (
        {
            name: 'vendor',
            minChunks: function (module)
            {
                return module.context && module.context.indexOf('node_modules') !== -1 ;
            }
        }
    ),
    new CommonsChunkPlugin
    (
        {
            name: 'manifest',
            minChunks: Infinity
        }
    ),
    extractCss,
    extractSass,
    ...
] ;

module.exports = webpackConfig ;

but it does not work.

However, if I replace the ExtractTextPlugin.extract parts with:

...
{
        test: /\.css$/,
        use:
        [
            {
                loader: 'style-loader'
            },
            {
                loader: 'css-loader'
            }
        ]
    },
    {
        test: /\.scss$/,
        use:
        [
            {
                loader: 'style-loader'
            },
            {
                loader: 'css-loader'
            },
            {
                loader: 'sass-loader'
            }
        ]
    }
...

it works...

Any idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant