Ignoring Global SCSS Webpack CSSModule











up vote
3
down vote

favorite












I'm trying to configure my webpack to use css modules for all the scss files except for the files in the "src/scss" and "node_modules" folder. Below are my configuration file






const webpack = require('webpack');
const combineLoaders = require('webpack-combine-loaders');
const ImageMinPlugin = require('imagemin-webpack-plugin').default;
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WebappWebpackPlugin = require('webapp-webpack-plugin');
const path = require('path');

const NODE_ENV = process.env.NODE_ENV || 'development';
const DEV_MODE = NODE_ENV !== 'production';
const PORT = process.env.PORT || 3000;
const FAVICON_DIR = './src/assets/favicon/favicon.png';
const ENTRY_CSS = path.resolve(__dirname, 'src/scss');
const NODE_MODULE_PATH = path.resolve(__dirname, 'node_modules')
console.log('ENTRY_CSS: ', ENTRY_CSS);
console.log('NODE_MODULE_PATH: ', NODE_MODULE_PATH);
const styleRules = () => [
{
test: /.scss$/,
exclude: [
ENTRY_CSS,
NODE_MODULE_PATH
],
loader: combineLoaders([
{
loader: 'style-loader',
},
{
loader: 'css-loader',
query: {
modules: true,
importLoaders: 1,
localIdentName: '[local]--[hash:base64:5]',
},
},
{
loader: 'postcss-loader',
options: {
plugins: function () {
return [
require('precss'),
require('autoprefixer')
];
}
}
},
{
loader: 'sass-loader',
query: {
includePaths: ['./src'],
},
},
]),
},
{
test: /.css$/,
include: [
path.resolve(__dirname, 'src')
],
loader: combineLoaders([
{
loader: 'style-loader',
},
{
loader: 'css-loader',
query: {
modules: true,
importLoaders: 1,
localIdentName: '[local]--[hash:base64:5]',
},
},
]),
},
/**
* for global style, import libs, no CSS module applied for those files imported here.
*/
{
test: /.scss$/,
include: [
ENTRY_CSS,
NODE_MODULE_PATH
],
loader: combineLoaders([
{
loader: 'style-loader',
},
{
loader: 'css-loader',
query: {
modules: false,
},
},
{
loader: 'postcss-loader',
options: {
plugins: function () {
return [
require('precss'),
require('autoprefixer')
];
}
}
},
{
loader: 'sass-loader',
query: {
includePaths: ['./src'],
},
},
]),
},
];

module.exports = {
entry: ['./src/index.tsx'],
mode: DEV_MODE ? 'development' : 'production',
devtool: DEV_MODE ? 'source-map' : '',
module: {
rules: [
{
test: /.tsx?$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader'
},
{
loader: 'ts-loader',
options: {
configFile: DEV_MODE ? 'tsconfig.json' : 'tsconfig.deploy.json',
},
},

],
},
...styleRules(),
{
test: /.(png|jpe?g|gif|svg)$/,
use: [
{
loader: 'file-loader',
options: {},
},
],
},
{
test: /.(ttf|eot|woff)(?v=[0-9].[0-9].[0-9])?$/,
use: [
{
loader: 'file-loader',
options: {},
},
],
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.json'],
},
output: {
path: __dirname + '/dist',
publicPath: '/',
filename: 'bundle.[hash].js',
},
devServer: {
contentBase: './dist',
compress: true,
port: PORT,
historyApiFallback: true,
open: true,
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
'process.env.PORT': JSON.stringify(PORT),
}),
new HtmlWebpackPlugin({
template: './src/index.html',
filename: 'index.html',
}),
...(FAVICON_DIR ? [new WebappWebpackPlugin(FAVICON_DIR)] : ),
new ImageMinPlugin({
disable: DEV_MODE,
pngquant: {
quality: '95-100',
},
test: /.(jpe?g|png|gif|svg)$/i,
}),
],
};





I'm importing Bootstrap's SCSS files in "main.scss" which is place inside the "src/scss" folder. The bootstrap files are also being hashed by css modules when I run my app. Can I know what mistake am I doing?










share|improve this question


























    up vote
    3
    down vote

    favorite












    I'm trying to configure my webpack to use css modules for all the scss files except for the files in the "src/scss" and "node_modules" folder. Below are my configuration file






    const webpack = require('webpack');
    const combineLoaders = require('webpack-combine-loaders');
    const ImageMinPlugin = require('imagemin-webpack-plugin').default;
    const HtmlWebpackPlugin = require('html-webpack-plugin');
    const WebappWebpackPlugin = require('webapp-webpack-plugin');
    const path = require('path');

    const NODE_ENV = process.env.NODE_ENV || 'development';
    const DEV_MODE = NODE_ENV !== 'production';
    const PORT = process.env.PORT || 3000;
    const FAVICON_DIR = './src/assets/favicon/favicon.png';
    const ENTRY_CSS = path.resolve(__dirname, 'src/scss');
    const NODE_MODULE_PATH = path.resolve(__dirname, 'node_modules')
    console.log('ENTRY_CSS: ', ENTRY_CSS);
    console.log('NODE_MODULE_PATH: ', NODE_MODULE_PATH);
    const styleRules = () => [
    {
    test: /.scss$/,
    exclude: [
    ENTRY_CSS,
    NODE_MODULE_PATH
    ],
    loader: combineLoaders([
    {
    loader: 'style-loader',
    },
    {
    loader: 'css-loader',
    query: {
    modules: true,
    importLoaders: 1,
    localIdentName: '[local]--[hash:base64:5]',
    },
    },
    {
    loader: 'postcss-loader',
    options: {
    plugins: function () {
    return [
    require('precss'),
    require('autoprefixer')
    ];
    }
    }
    },
    {
    loader: 'sass-loader',
    query: {
    includePaths: ['./src'],
    },
    },
    ]),
    },
    {
    test: /.css$/,
    include: [
    path.resolve(__dirname, 'src')
    ],
    loader: combineLoaders([
    {
    loader: 'style-loader',
    },
    {
    loader: 'css-loader',
    query: {
    modules: true,
    importLoaders: 1,
    localIdentName: '[local]--[hash:base64:5]',
    },
    },
    ]),
    },
    /**
    * for global style, import libs, no CSS module applied for those files imported here.
    */
    {
    test: /.scss$/,
    include: [
    ENTRY_CSS,
    NODE_MODULE_PATH
    ],
    loader: combineLoaders([
    {
    loader: 'style-loader',
    },
    {
    loader: 'css-loader',
    query: {
    modules: false,
    },
    },
    {
    loader: 'postcss-loader',
    options: {
    plugins: function () {
    return [
    require('precss'),
    require('autoprefixer')
    ];
    }
    }
    },
    {
    loader: 'sass-loader',
    query: {
    includePaths: ['./src'],
    },
    },
    ]),
    },
    ];

    module.exports = {
    entry: ['./src/index.tsx'],
    mode: DEV_MODE ? 'development' : 'production',
    devtool: DEV_MODE ? 'source-map' : '',
    module: {
    rules: [
    {
    test: /.tsx?$/,
    exclude: /node_modules/,
    use: [
    {
    loader: 'babel-loader'
    },
    {
    loader: 'ts-loader',
    options: {
    configFile: DEV_MODE ? 'tsconfig.json' : 'tsconfig.deploy.json',
    },
    },

    ],
    },
    ...styleRules(),
    {
    test: /.(png|jpe?g|gif|svg)$/,
    use: [
    {
    loader: 'file-loader',
    options: {},
    },
    ],
    },
    {
    test: /.(ttf|eot|woff)(?v=[0-9].[0-9].[0-9])?$/,
    use: [
    {
    loader: 'file-loader',
    options: {},
    },
    ],
    },
    ],
    },
    resolve: {
    extensions: ['.tsx', '.ts', '.js', '.json'],
    },
    output: {
    path: __dirname + '/dist',
    publicPath: '/',
    filename: 'bundle.[hash].js',
    },
    devServer: {
    contentBase: './dist',
    compress: true,
    port: PORT,
    historyApiFallback: true,
    open: true,
    },
    plugins: [
    new webpack.DefinePlugin({
    'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
    'process.env.PORT': JSON.stringify(PORT),
    }),
    new HtmlWebpackPlugin({
    template: './src/index.html',
    filename: 'index.html',
    }),
    ...(FAVICON_DIR ? [new WebappWebpackPlugin(FAVICON_DIR)] : ),
    new ImageMinPlugin({
    disable: DEV_MODE,
    pngquant: {
    quality: '95-100',
    },
    test: /.(jpe?g|png|gif|svg)$/i,
    }),
    ],
    };





    I'm importing Bootstrap's SCSS files in "main.scss" which is place inside the "src/scss" folder. The bootstrap files are also being hashed by css modules when I run my app. Can I know what mistake am I doing?










    share|improve this question
























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      I'm trying to configure my webpack to use css modules for all the scss files except for the files in the "src/scss" and "node_modules" folder. Below are my configuration file






      const webpack = require('webpack');
      const combineLoaders = require('webpack-combine-loaders');
      const ImageMinPlugin = require('imagemin-webpack-plugin').default;
      const HtmlWebpackPlugin = require('html-webpack-plugin');
      const WebappWebpackPlugin = require('webapp-webpack-plugin');
      const path = require('path');

      const NODE_ENV = process.env.NODE_ENV || 'development';
      const DEV_MODE = NODE_ENV !== 'production';
      const PORT = process.env.PORT || 3000;
      const FAVICON_DIR = './src/assets/favicon/favicon.png';
      const ENTRY_CSS = path.resolve(__dirname, 'src/scss');
      const NODE_MODULE_PATH = path.resolve(__dirname, 'node_modules')
      console.log('ENTRY_CSS: ', ENTRY_CSS);
      console.log('NODE_MODULE_PATH: ', NODE_MODULE_PATH);
      const styleRules = () => [
      {
      test: /.scss$/,
      exclude: [
      ENTRY_CSS,
      NODE_MODULE_PATH
      ],
      loader: combineLoaders([
      {
      loader: 'style-loader',
      },
      {
      loader: 'css-loader',
      query: {
      modules: true,
      importLoaders: 1,
      localIdentName: '[local]--[hash:base64:5]',
      },
      },
      {
      loader: 'postcss-loader',
      options: {
      plugins: function () {
      return [
      require('precss'),
      require('autoprefixer')
      ];
      }
      }
      },
      {
      loader: 'sass-loader',
      query: {
      includePaths: ['./src'],
      },
      },
      ]),
      },
      {
      test: /.css$/,
      include: [
      path.resolve(__dirname, 'src')
      ],
      loader: combineLoaders([
      {
      loader: 'style-loader',
      },
      {
      loader: 'css-loader',
      query: {
      modules: true,
      importLoaders: 1,
      localIdentName: '[local]--[hash:base64:5]',
      },
      },
      ]),
      },
      /**
      * for global style, import libs, no CSS module applied for those files imported here.
      */
      {
      test: /.scss$/,
      include: [
      ENTRY_CSS,
      NODE_MODULE_PATH
      ],
      loader: combineLoaders([
      {
      loader: 'style-loader',
      },
      {
      loader: 'css-loader',
      query: {
      modules: false,
      },
      },
      {
      loader: 'postcss-loader',
      options: {
      plugins: function () {
      return [
      require('precss'),
      require('autoprefixer')
      ];
      }
      }
      },
      {
      loader: 'sass-loader',
      query: {
      includePaths: ['./src'],
      },
      },
      ]),
      },
      ];

      module.exports = {
      entry: ['./src/index.tsx'],
      mode: DEV_MODE ? 'development' : 'production',
      devtool: DEV_MODE ? 'source-map' : '',
      module: {
      rules: [
      {
      test: /.tsx?$/,
      exclude: /node_modules/,
      use: [
      {
      loader: 'babel-loader'
      },
      {
      loader: 'ts-loader',
      options: {
      configFile: DEV_MODE ? 'tsconfig.json' : 'tsconfig.deploy.json',
      },
      },

      ],
      },
      ...styleRules(),
      {
      test: /.(png|jpe?g|gif|svg)$/,
      use: [
      {
      loader: 'file-loader',
      options: {},
      },
      ],
      },
      {
      test: /.(ttf|eot|woff)(?v=[0-9].[0-9].[0-9])?$/,
      use: [
      {
      loader: 'file-loader',
      options: {},
      },
      ],
      },
      ],
      },
      resolve: {
      extensions: ['.tsx', '.ts', '.js', '.json'],
      },
      output: {
      path: __dirname + '/dist',
      publicPath: '/',
      filename: 'bundle.[hash].js',
      },
      devServer: {
      contentBase: './dist',
      compress: true,
      port: PORT,
      historyApiFallback: true,
      open: true,
      },
      plugins: [
      new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
      'process.env.PORT': JSON.stringify(PORT),
      }),
      new HtmlWebpackPlugin({
      template: './src/index.html',
      filename: 'index.html',
      }),
      ...(FAVICON_DIR ? [new WebappWebpackPlugin(FAVICON_DIR)] : ),
      new ImageMinPlugin({
      disable: DEV_MODE,
      pngquant: {
      quality: '95-100',
      },
      test: /.(jpe?g|png|gif|svg)$/i,
      }),
      ],
      };





      I'm importing Bootstrap's SCSS files in "main.scss" which is place inside the "src/scss" folder. The bootstrap files are also being hashed by css modules when I run my app. Can I know what mistake am I doing?










      share|improve this question













      I'm trying to configure my webpack to use css modules for all the scss files except for the files in the "src/scss" and "node_modules" folder. Below are my configuration file






      const webpack = require('webpack');
      const combineLoaders = require('webpack-combine-loaders');
      const ImageMinPlugin = require('imagemin-webpack-plugin').default;
      const HtmlWebpackPlugin = require('html-webpack-plugin');
      const WebappWebpackPlugin = require('webapp-webpack-plugin');
      const path = require('path');

      const NODE_ENV = process.env.NODE_ENV || 'development';
      const DEV_MODE = NODE_ENV !== 'production';
      const PORT = process.env.PORT || 3000;
      const FAVICON_DIR = './src/assets/favicon/favicon.png';
      const ENTRY_CSS = path.resolve(__dirname, 'src/scss');
      const NODE_MODULE_PATH = path.resolve(__dirname, 'node_modules')
      console.log('ENTRY_CSS: ', ENTRY_CSS);
      console.log('NODE_MODULE_PATH: ', NODE_MODULE_PATH);
      const styleRules = () => [
      {
      test: /.scss$/,
      exclude: [
      ENTRY_CSS,
      NODE_MODULE_PATH
      ],
      loader: combineLoaders([
      {
      loader: 'style-loader',
      },
      {
      loader: 'css-loader',
      query: {
      modules: true,
      importLoaders: 1,
      localIdentName: '[local]--[hash:base64:5]',
      },
      },
      {
      loader: 'postcss-loader',
      options: {
      plugins: function () {
      return [
      require('precss'),
      require('autoprefixer')
      ];
      }
      }
      },
      {
      loader: 'sass-loader',
      query: {
      includePaths: ['./src'],
      },
      },
      ]),
      },
      {
      test: /.css$/,
      include: [
      path.resolve(__dirname, 'src')
      ],
      loader: combineLoaders([
      {
      loader: 'style-loader',
      },
      {
      loader: 'css-loader',
      query: {
      modules: true,
      importLoaders: 1,
      localIdentName: '[local]--[hash:base64:5]',
      },
      },
      ]),
      },
      /**
      * for global style, import libs, no CSS module applied for those files imported here.
      */
      {
      test: /.scss$/,
      include: [
      ENTRY_CSS,
      NODE_MODULE_PATH
      ],
      loader: combineLoaders([
      {
      loader: 'style-loader',
      },
      {
      loader: 'css-loader',
      query: {
      modules: false,
      },
      },
      {
      loader: 'postcss-loader',
      options: {
      plugins: function () {
      return [
      require('precss'),
      require('autoprefixer')
      ];
      }
      }
      },
      {
      loader: 'sass-loader',
      query: {
      includePaths: ['./src'],
      },
      },
      ]),
      },
      ];

      module.exports = {
      entry: ['./src/index.tsx'],
      mode: DEV_MODE ? 'development' : 'production',
      devtool: DEV_MODE ? 'source-map' : '',
      module: {
      rules: [
      {
      test: /.tsx?$/,
      exclude: /node_modules/,
      use: [
      {
      loader: 'babel-loader'
      },
      {
      loader: 'ts-loader',
      options: {
      configFile: DEV_MODE ? 'tsconfig.json' : 'tsconfig.deploy.json',
      },
      },

      ],
      },
      ...styleRules(),
      {
      test: /.(png|jpe?g|gif|svg)$/,
      use: [
      {
      loader: 'file-loader',
      options: {},
      },
      ],
      },
      {
      test: /.(ttf|eot|woff)(?v=[0-9].[0-9].[0-9])?$/,
      use: [
      {
      loader: 'file-loader',
      options: {},
      },
      ],
      },
      ],
      },
      resolve: {
      extensions: ['.tsx', '.ts', '.js', '.json'],
      },
      output: {
      path: __dirname + '/dist',
      publicPath: '/',
      filename: 'bundle.[hash].js',
      },
      devServer: {
      contentBase: './dist',
      compress: true,
      port: PORT,
      historyApiFallback: true,
      open: true,
      },
      plugins: [
      new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
      'process.env.PORT': JSON.stringify(PORT),
      }),
      new HtmlWebpackPlugin({
      template: './src/index.html',
      filename: 'index.html',
      }),
      ...(FAVICON_DIR ? [new WebappWebpackPlugin(FAVICON_DIR)] : ),
      new ImageMinPlugin({
      disable: DEV_MODE,
      pngquant: {
      quality: '95-100',
      },
      test: /.(jpe?g|png|gif|svg)$/i,
      }),
      ],
      };





      I'm importing Bootstrap's SCSS files in "main.scss" which is place inside the "src/scss" folder. The bootstrap files are also being hashed by css modules when I run my app. Can I know what mistake am I doing?






      const webpack = require('webpack');
      const combineLoaders = require('webpack-combine-loaders');
      const ImageMinPlugin = require('imagemin-webpack-plugin').default;
      const HtmlWebpackPlugin = require('html-webpack-plugin');
      const WebappWebpackPlugin = require('webapp-webpack-plugin');
      const path = require('path');

      const NODE_ENV = process.env.NODE_ENV || 'development';
      const DEV_MODE = NODE_ENV !== 'production';
      const PORT = process.env.PORT || 3000;
      const FAVICON_DIR = './src/assets/favicon/favicon.png';
      const ENTRY_CSS = path.resolve(__dirname, 'src/scss');
      const NODE_MODULE_PATH = path.resolve(__dirname, 'node_modules')
      console.log('ENTRY_CSS: ', ENTRY_CSS);
      console.log('NODE_MODULE_PATH: ', NODE_MODULE_PATH);
      const styleRules = () => [
      {
      test: /.scss$/,
      exclude: [
      ENTRY_CSS,
      NODE_MODULE_PATH
      ],
      loader: combineLoaders([
      {
      loader: 'style-loader',
      },
      {
      loader: 'css-loader',
      query: {
      modules: true,
      importLoaders: 1,
      localIdentName: '[local]--[hash:base64:5]',
      },
      },
      {
      loader: 'postcss-loader',
      options: {
      plugins: function () {
      return [
      require('precss'),
      require('autoprefixer')
      ];
      }
      }
      },
      {
      loader: 'sass-loader',
      query: {
      includePaths: ['./src'],
      },
      },
      ]),
      },
      {
      test: /.css$/,
      include: [
      path.resolve(__dirname, 'src')
      ],
      loader: combineLoaders([
      {
      loader: 'style-loader',
      },
      {
      loader: 'css-loader',
      query: {
      modules: true,
      importLoaders: 1,
      localIdentName: '[local]--[hash:base64:5]',
      },
      },
      ]),
      },
      /**
      * for global style, import libs, no CSS module applied for those files imported here.
      */
      {
      test: /.scss$/,
      include: [
      ENTRY_CSS,
      NODE_MODULE_PATH
      ],
      loader: combineLoaders([
      {
      loader: 'style-loader',
      },
      {
      loader: 'css-loader',
      query: {
      modules: false,
      },
      },
      {
      loader: 'postcss-loader',
      options: {
      plugins: function () {
      return [
      require('precss'),
      require('autoprefixer')
      ];
      }
      }
      },
      {
      loader: 'sass-loader',
      query: {
      includePaths: ['./src'],
      },
      },
      ]),
      },
      ];

      module.exports = {
      entry: ['./src/index.tsx'],
      mode: DEV_MODE ? 'development' : 'production',
      devtool: DEV_MODE ? 'source-map' : '',
      module: {
      rules: [
      {
      test: /.tsx?$/,
      exclude: /node_modules/,
      use: [
      {
      loader: 'babel-loader'
      },
      {
      loader: 'ts-loader',
      options: {
      configFile: DEV_MODE ? 'tsconfig.json' : 'tsconfig.deploy.json',
      },
      },

      ],
      },
      ...styleRules(),
      {
      test: /.(png|jpe?g|gif|svg)$/,
      use: [
      {
      loader: 'file-loader',
      options: {},
      },
      ],
      },
      {
      test: /.(ttf|eot|woff)(?v=[0-9].[0-9].[0-9])?$/,
      use: [
      {
      loader: 'file-loader',
      options: {},
      },
      ],
      },
      ],
      },
      resolve: {
      extensions: ['.tsx', '.ts', '.js', '.json'],
      },
      output: {
      path: __dirname + '/dist',
      publicPath: '/',
      filename: 'bundle.[hash].js',
      },
      devServer: {
      contentBase: './dist',
      compress: true,
      port: PORT,
      historyApiFallback: true,
      open: true,
      },
      plugins: [
      new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
      'process.env.PORT': JSON.stringify(PORT),
      }),
      new HtmlWebpackPlugin({
      template: './src/index.html',
      filename: 'index.html',
      }),
      ...(FAVICON_DIR ? [new WebappWebpackPlugin(FAVICON_DIR)] : ),
      new ImageMinPlugin({
      disable: DEV_MODE,
      pngquant: {
      quality: '95-100',
      },
      test: /.(jpe?g|png|gif|svg)$/i,
      }),
      ],
      };





      const webpack = require('webpack');
      const combineLoaders = require('webpack-combine-loaders');
      const ImageMinPlugin = require('imagemin-webpack-plugin').default;
      const HtmlWebpackPlugin = require('html-webpack-plugin');
      const WebappWebpackPlugin = require('webapp-webpack-plugin');
      const path = require('path');

      const NODE_ENV = process.env.NODE_ENV || 'development';
      const DEV_MODE = NODE_ENV !== 'production';
      const PORT = process.env.PORT || 3000;
      const FAVICON_DIR = './src/assets/favicon/favicon.png';
      const ENTRY_CSS = path.resolve(__dirname, 'src/scss');
      const NODE_MODULE_PATH = path.resolve(__dirname, 'node_modules')
      console.log('ENTRY_CSS: ', ENTRY_CSS);
      console.log('NODE_MODULE_PATH: ', NODE_MODULE_PATH);
      const styleRules = () => [
      {
      test: /.scss$/,
      exclude: [
      ENTRY_CSS,
      NODE_MODULE_PATH
      ],
      loader: combineLoaders([
      {
      loader: 'style-loader',
      },
      {
      loader: 'css-loader',
      query: {
      modules: true,
      importLoaders: 1,
      localIdentName: '[local]--[hash:base64:5]',
      },
      },
      {
      loader: 'postcss-loader',
      options: {
      plugins: function () {
      return [
      require('precss'),
      require('autoprefixer')
      ];
      }
      }
      },
      {
      loader: 'sass-loader',
      query: {
      includePaths: ['./src'],
      },
      },
      ]),
      },
      {
      test: /.css$/,
      include: [
      path.resolve(__dirname, 'src')
      ],
      loader: combineLoaders([
      {
      loader: 'style-loader',
      },
      {
      loader: 'css-loader',
      query: {
      modules: true,
      importLoaders: 1,
      localIdentName: '[local]--[hash:base64:5]',
      },
      },
      ]),
      },
      /**
      * for global style, import libs, no CSS module applied for those files imported here.
      */
      {
      test: /.scss$/,
      include: [
      ENTRY_CSS,
      NODE_MODULE_PATH
      ],
      loader: combineLoaders([
      {
      loader: 'style-loader',
      },
      {
      loader: 'css-loader',
      query: {
      modules: false,
      },
      },
      {
      loader: 'postcss-loader',
      options: {
      plugins: function () {
      return [
      require('precss'),
      require('autoprefixer')
      ];
      }
      }
      },
      {
      loader: 'sass-loader',
      query: {
      includePaths: ['./src'],
      },
      },
      ]),
      },
      ];

      module.exports = {
      entry: ['./src/index.tsx'],
      mode: DEV_MODE ? 'development' : 'production',
      devtool: DEV_MODE ? 'source-map' : '',
      module: {
      rules: [
      {
      test: /.tsx?$/,
      exclude: /node_modules/,
      use: [
      {
      loader: 'babel-loader'
      },
      {
      loader: 'ts-loader',
      options: {
      configFile: DEV_MODE ? 'tsconfig.json' : 'tsconfig.deploy.json',
      },
      },

      ],
      },
      ...styleRules(),
      {
      test: /.(png|jpe?g|gif|svg)$/,
      use: [
      {
      loader: 'file-loader',
      options: {},
      },
      ],
      },
      {
      test: /.(ttf|eot|woff)(?v=[0-9].[0-9].[0-9])?$/,
      use: [
      {
      loader: 'file-loader',
      options: {},
      },
      ],
      },
      ],
      },
      resolve: {
      extensions: ['.tsx', '.ts', '.js', '.json'],
      },
      output: {
      path: __dirname + '/dist',
      publicPath: '/',
      filename: 'bundle.[hash].js',
      },
      devServer: {
      contentBase: './dist',
      compress: true,
      port: PORT,
      historyApiFallback: true,
      open: true,
      },
      plugins: [
      new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
      'process.env.PORT': JSON.stringify(PORT),
      }),
      new HtmlWebpackPlugin({
      template: './src/index.html',
      filename: 'index.html',
      }),
      ...(FAVICON_DIR ? [new WebappWebpackPlugin(FAVICON_DIR)] : ),
      new ImageMinPlugin({
      disable: DEV_MODE,
      pngquant: {
      quality: '95-100',
      },
      test: /.(jpe?g|png|gif|svg)$/i,
      }),
      ],
      };






      javascript css webpack sass css-modules






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 10 at 15:37









      user2672399

      365




      365
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          You can use exclude option of css-loader,



          loaders: [{
          test: /.scss$/,
          exclude: fs.realpathSync('./node_modules/path/to/bootstrap/src/styles')
          loader: cssModulesLoader,
          }





          share|improve this answer





















          • It's still doesn't work. Isn't this the exact way i tried above? Thank you.
            – user2672399
            Nov 10 at 23:50











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240511%2fignoring-global-scss-webpack-cssmodule%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          You can use exclude option of css-loader,



          loaders: [{
          test: /.scss$/,
          exclude: fs.realpathSync('./node_modules/path/to/bootstrap/src/styles')
          loader: cssModulesLoader,
          }





          share|improve this answer





















          • It's still doesn't work. Isn't this the exact way i tried above? Thank you.
            – user2672399
            Nov 10 at 23:50















          up vote
          0
          down vote













          You can use exclude option of css-loader,



          loaders: [{
          test: /.scss$/,
          exclude: fs.realpathSync('./node_modules/path/to/bootstrap/src/styles')
          loader: cssModulesLoader,
          }





          share|improve this answer





















          • It's still doesn't work. Isn't this the exact way i tried above? Thank you.
            – user2672399
            Nov 10 at 23:50













          up vote
          0
          down vote










          up vote
          0
          down vote









          You can use exclude option of css-loader,



          loaders: [{
          test: /.scss$/,
          exclude: fs.realpathSync('./node_modules/path/to/bootstrap/src/styles')
          loader: cssModulesLoader,
          }





          share|improve this answer












          You can use exclude option of css-loader,



          loaders: [{
          test: /.scss$/,
          exclude: fs.realpathSync('./node_modules/path/to/bootstrap/src/styles')
          loader: cssModulesLoader,
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 10 at 18:02









          felixmosh

          3,6022517




          3,6022517












          • It's still doesn't work. Isn't this the exact way i tried above? Thank you.
            – user2672399
            Nov 10 at 23:50


















          • It's still doesn't work. Isn't this the exact way i tried above? Thank you.
            – user2672399
            Nov 10 at 23:50
















          It's still doesn't work. Isn't this the exact way i tried above? Thank you.
          – user2672399
          Nov 10 at 23:50




          It's still doesn't work. Isn't this the exact way i tried above? Thank you.
          – user2672399
          Nov 10 at 23:50


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240511%2fignoring-global-scss-webpack-cssmodule%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Florida Star v. B. J. F.

          Danny Elfman

          Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues