I have a Webpack 3 setup using ExtractTextPlugin
, and the localIdentName
is not applying to the CSS classes generated from node_modules
, specifically from the react-spinkit
package.
I am using a <Spinner />
component from react-spinkit
, which is producing the following CSS class:
You'll see that the classes imported by the module are clearly not having the
localIdentName
hash applied to them.
ExtractTextPlugin
seems to be generating the classnames properly, as demonstrated in my app.css
output file:
Webpack is always making me learn how it works every time I use it. Here is my configuration file:
const path = require('path');
const webpack = require('webpack');
const { CheckerPlugin } = require('awesome-typescript-loader');
const ManifestPlugin = require('webpack-manifest-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const config = {
devtool: 'source-map',
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx', '.css'],
modules: ['node_modules', 'app'],
alias: {
Assets: path.resolve(__dirname, '../../src/assets')
}
},
entry: {
app: [
'webpack-hot-middleware/client?reload=true',
'./src/client.tsx'
]
},
output: {
path: path.resolve('./build/public'),
publicPath: '/public/',
filename: 'js/[name].js',
pathinfo: true
},
module: {
rules: [{
enforce: 'pre',
test: /\.tsx?$/,
loader: 'tslint-loader'
},
{
test: /\.tsx?$/,
loader: 'react-hot-loader!awesome-typescript-loader'
},
{
test: /\.jsx$/,
loader: 'babel-loader'
},
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
importLoaders: 1,
localIdentName: '[path][name]__[local]--[hash:base64:5]',
modules: true
}
},
'postcss-loader'
]
}),
},
{
test: /\.eot(\?.*)?$/,
loader: 'file-loader?name=fonts/[hash].[ext]'
},
{
test: /\.(woff|woff2)(\?.*)?$/,
loader: 'file-loader?name=fonts/[hash].[ext]'
},
{
test: /\.ttf(\?.*)?$/,
loader: 'url-loader?limit=10000&mimetype=application/octet-stream&name=fonts/[hash].[ext]'
},
{
test: /\.svg(\?.*)?$/,
loader: 'url-loader?limit=10000&mimetype=image/svg+xml&name=fonts/[hash].[ext]'
},
{
test: /\.(jpe?g|png|gif)$/i,
loader: 'url-loader?limit=1000&name=images/[hash].[ext]'
}
]
},
plugins: [
new CheckerPlugin(),
new ManifestPlugin({
fileName: '../manifest.json'
}),
new webpack.DefinePlugin({
'process.env': {
BROWSER: JSON.stringify(true),
NODE_ENV: JSON.stringify('development')
}
}),
new ExtractTextPlugin('[name].css'),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin()
]
};
Thanks for the input in advance!