なぜCSSセグメントがでないのかわかります。は'style-ext-html-webpack-plugin'
です。webpack:スプラッシュ画面のインラインCSS(折りたたみCSSの上に)
現在、私は.CSS
ファイルにスプラッシュ画面のルールを設定しています。
'extract-text-webpack-plugin'
を用いてそれを抽出し、テンプレート<head>
に'extract-text-webpack-plugin'
で注射した。
問題は、ファイルが決して'style-ext-html-webpack-plugin'
を経由して実行されないため、私はそれをどのようにデバッグするかについて頭を悩ますことができません。
(理想的には、私はそれが.env
ファイルを通じてテーマに対応できるように.SCSS
ファイルを持っているしたいと思いますつまり:。splash.scss
が独占的にいくつかのテーマの色を注入された後に抽出し<head>
にインライン化している)
webpack.config.js:
....
const ExtractTextPlugin = require('extract-text-webpack-plugin'); //used for above-the-fold css (such as splash-screen)
const StyleExtHtmlPlugin = require('style-ext-html-webpack-plugin');
const extractSplashCSS = new ExtractTextPlugin('splash.css');
module.exports = {
entry: {...},
output: {...},
resolve: {...},
plugins: [
...,
new HtmlWebpackPlugin({
title: enviroments.TITLE,
splashScreenTitle: enviroments.SPLASH_SCREEN_TITLE,
template: 'src/index.html',
cache: true,
favicon: enviroments.FAVICON || './src/assets/images/favicon.ico',
inject: 'body'
}),
extractSplashCSS,
new StyleExtHtmlPlugin('splash.css')
],
module: {
loaders: [
{ test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ },
{
test: /\.css$/,
loader: 'style-loader!css-loader!resolve-url-loader?import=false',
exclude: [path.join(path.resolve('./src'), 'common/app/splash.css')]
},
{
test: /\.css$/,
loader: extractSplashCSS.extract({
use: 'css-loader'
}),
include: [path.join(path.resolve('./src'), 'common/app/splash.css')]
},
{
test: /\.scss$/,
use: [
'style-loader',
'css-loader?importLoaders=1',
{
loader: 'postcss-loader',
options: {
plugins: function() {
return [require('autoprefixer')];
}
}
},
'resolve-url-loader?sourceMap',
{
loader: 'sass-loader?sourceMap',
options: {
includePaths: path.resolve('./src'),
data: `
$color-primary: ${theme.PRIMARY};
....
`
}
}
]
},
....
]
}
};
index.js:
...
// above the fold css
import 'common/app/splash.css';