Webpack 3 - ExtractTextPlugin - localIdentName not applied to component from node_modules
I have a Webpack 3 installation using ExtractTextPlugin
and localIdentName
not being applied to CSS classes generated from node_modules
, specifically from a package react-spinkit
.
I am using a component <Spinner />
from react-spinkit
which creates the following CSS class:
You will see that the classes imported by the module do not explicitly use a hash localIdentName
to them.
ExtractTextPlugin
seems to generate the class names correctly as shown in my output file app.css
:
Webpack always makes me know how it works every time I use it. Here is my config 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 entering in advance!
source to share
No one has answered this question yet
Check out similar questions: