// 入口文件app.js
import "./icomoon/style.css"; // 以.css结尾,单独打包,初衷是想把第三方引入的css单独打包成一个css文件
import "./scss/app.scss";
import React from 'react';
import ReactDOM from 'react-dom';
import RouterMap from './router/Router';
ReactDOM.render(
<RouterMap />,
document.getElementById('root')
);
// Router.js
import Index from '../pages/Index';
// Index.js
import Header from '../components/Header/index';
import Footer from '../components/Footer/index';
// Header.js
import './header.scss';
// Footer.js
import './footer.scss';
// webpack.config.js
const extractCSS = new ExtractTextPlugin('css/vender.[chunkhash:8].css');
const extractSCSS = new ExtractTextPlugin('css/app.[chunkhash:8].css');
// loader
{
test: /\.css$/,
use: extractCSS.extract({
fallback: 'style-loader',
use: [{
loader: 'css-loader',
options: {
minimize: true
}
},
{
loader: 'postcss-loader',
options: { plugins: [require('autoprefixer')] }
}
]
})
},
{
test: /\.scss$/,
use: extractSCSS.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
minimize: true
}
},
{
loader: 'postcss-loader',
options: { plugins: [require('autoprefixer')] }
},
'sass-loader'
]
})
}
会打包生成vender.css和app.css两份文件,其中app.css我期望打包出来的css顺序是:app.scss > header.scss > footer.scss
,但是实际打包出来的是:header.scss > footer.scss > app.scss
求助,谢谢!
好像是个一直未解决的bug:https://github.com/webpack/we...