Wrong component styles in angular when bundling in production with webpack

356 views Asked by At

I am developing a web-app using angular, third-party components and webpack.

When i am bundling everything in production mode, some components seems to not apply in a right way the styles that they have in development mode. For example:

ngx-chips component. Issue opened in github

Development: Production:

ng2-smart-table component Issue opened in github

Development: Production:

I am not sure at all that is a fail of the own component or not.

Here is the webpack.config.common.js that i am using

var webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const extractSass = new ExtractTextPlugin({
    filename: "bundle.css",
    disable: process.env.NODE_ENV === "development"
});

module.exports = {
    entry: {
        'app': './assets/app/main.ts'
    },

    resolve: {
        extensions: ['.js', '.ts']
    },

    module: {
        rules: [
            {
                test: /\.html$/,
                use: [{ loader: 'html-loader' }]
            },
            {
                test: /\.css$/,
                use: [{ loader: 'raw-loader' }]
            },
            {
                test: /\.scss$/,
                use: extractSass.extract({
                    use: [{
                        loader: "css-loader"
                    }, {
                        loader: "sass-loader"
                    }],
                    fallback: "style-loader"
                })
            }]
        ,
        noParse: [
            /aws-sdk/
        ],
        loaders: [
            {
                test: /.json$/,
                loaders: ['json']
            },
        ],
        exprContextCritical: false

    }
};

And here is the scripts that i am using to bundle with webpack:

  "scripts": {
"start": "node ./bin/www",
"build": "del-cli public/js/app && webpack --config webpack.config.dev.js --progress --profile --watch",
"build:prod": "del-cli public/js/app && ngc -p tsconfig.aot.json && ngc -p tsconfig.aot.json && webpack --config webpack.config.prod.js --progress --profile --bail && del-cli 'public/js/app/**/*.js' 'public/js/app/**/*.js.map' '!public/js/app/bundle.js' '!public/js/app/*.chunk.js' 'assets/app/**/*.ngfactory.ts' 'assets/app/**/*.shim.ts' 'assets/app/**/*.ngsummary.json' 'assets/app/**/*.ngstyle.ts'"

I would appreciate too much your help!

0

There are 0 answers