const path = require('path');
var webpack = require('webpack'),
ExtractTextPlugin = require("extract-text-webpack-plugin");
var nodeExternals = require('webpack-node-externals');
const CssEntryPlugin = require("css-entry-webpack-plugin");
module.exports = {
entry: {
index: './js/index.js',
product_details: './js/index.js',
signup: ['./js/signup.js','./js/index.js'],
signup_style: ['./css/signup.css']
},
output: {
path: path.resolve(__dirname, 'dist/js'),
filename: "[name].min.js"
},
externals: [nodeExternals()],
module: {
rules: [
{
test: /\.js/,
use: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [{
loader: 'css-loader',
options: {
minimize: true,
}
}]
})
}
]
},
plugins: [
new ExtractTextPlugin('../css/[name].css')
]
};
Above is my webpack.config.js file. It creates signup_style.min.js and signup_style.css files. I want only signup_style.css file to create and not signup_style.min.js.
How can we do that?
const path = require('path');
var webpack = require('webpack'),
ExtractTextPlugin = require("extract-text-webpack-plugin");
var nodeExternals = require('webpack-node-externals');
const CssEntryPlugin = require("css-entry-webpack-plugin");
module.exports = {
entry: {
index: './js/index.js',
product_details: './js/index.js',
signup: ['./js/signup.js','./js/index.js'],
signup_style: ['./css/signup.css']
},
output: {
path: path.resolve(__dirname, 'dist/js'),
filename: "[name].min.js"
},
externals: [nodeExternals()],
module: {
rules: [
{
test: /\.js/,
use: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [{
loader: 'css-loader',
options: {
minimize: true,
}
}]
})
}
]
},
plugins: [
new ExtractTextPlugin('../css/[name].css')
]
};
Above is my webpack.config.js file. It creates signup_style.min.js and signup_style.css files. I want only signup_style.css file to create and not signup_style.min.js.
How can we do that?
Share Improve this question edited Feb 26, 2018 at 8:31 Rick 3,4511 gold badge23 silver badges29 bronze badges asked Feb 26, 2018 at 7:52 TruptiTrupti 9732 gold badges15 silver badges30 bronze badges 1 |2 Answers
Reset to default 18You can use https://www.npmjs.com/package/webpack-fix-style-only-entries
This is a small plugin developed to solve the problem of having a style only entry (css/sass/less) generating an extra js file.
By default webpack will generate that .min.js file. As in your configuration output
all the entry files must generate
its js files.
Note: extract-text-webpack-plugin will extract all css/sass located in your js entry files.
It moves all the required *.css modules in entry chunks into a separate CSS file. So your styles are no longer inlined into the JS bundle, but in a separate CSS file (styles.css).
All you need to do is to remove that file if you don't want it. I am using https://github.com/gregnb/filemanager-webpack-plugin/. Where you can define what files you will remove before or after webpack bundling.
test: /\.js/,
totest: /\.js$/,
– Ganesh Commented Feb 26, 2018 at 8:52