我使用多個入口點(一個生成綁定的js文件(main.js),另一個生成css文件(style.css)。我的webpack.config.js文件是產生這兩個文件也是一個style.js文件如何讓它不產生style.js文件webpack生成不必要的輸出文件
webpack.config.js:?
'use strict';
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
devtool: 'eval-source-map',
entry: {
main: [
'webpack-hot-middleware/client?reload=true',
path.join(__dirname, './app/main.js')],
style: [
'webpack-hot-middleware/client?reload=true',
path.join(__dirname, './app/main.css')]},
// any way to indicate that only the 1st entry point should be output to a file?
output: {
path: path.join(__dirname, '/dist/'),
filename: '[name].js',
publicPath: '/'
},
plugins: [
new HtmlWebpackPlugin({
template: 'app/index.tpl.html',
inject: 'body',
filename: 'index.html'
}),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development')
}),
new ExtractTextPlugin("[name].css")
],
module: {
rules: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
"presets": ["react", ["es2015", { "modules": false }], "stage-0", "react-hmre"]
}
}, {
test: /\.json?$/,
loader: 'json'
}, {
test: /\.css$/,
loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' })
}]
}
};
的ExtractTextPlugin使用樣式的進出點爲了生成css文件,我不想在bundle輸出中使用這個入口點,有什麼辦法只讓主(第1)入口點用於輸出嗎?或者我應該改變我的方法來生成style.css文件完全?