Skip to content

Commit

Permalink
feat(build-config): update to latest alpha of extract text plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
dmbch authored and ZauberNerd committed Mar 26, 2018
1 parent 6a61523 commit 823b562
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
6 changes: 6 additions & 0 deletions packages/build-config/configs/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var path = require('path');
var webpack = require('webpack');
var StatsWriterPlugin = require('webpack-stats-plugin').StatsWriterPlugin;
var ServiceWorkerPlugin = require('../plugins/service-worker');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

var hopsConfig = require('hops-config');

Expand Down Expand Up @@ -58,6 +59,11 @@ module.exports = {
plugins: [
new StatsWriterPlugin({ fields: null }),
new ServiceWorkerPlugin(),
new ExtractTextPlugin({
filename: getAssetPath('[name]-[contenthash:16].css'),
allChunks: true,
ignoreOrder: true,
}),
new webpack.HashedModuleIdsPlugin(),
new webpack.EnvironmentPlugin(
Object.assign(
Expand Down
2 changes: 1 addition & 1 deletion packages/build-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"babel-preset-react": "^6.24.1",
"caniuse-lite": "^1.0.30000789",
"css-loader": "^0.28.8",
"extract-text-webpack-plugin": "webpack-contrib/extract-text-webpack-plugin#next",
"extract-text-webpack-plugin": "^4.0.0-alpha.0",
"file-loader": "^1.1.6",
"find-up": "^2.1.0",
"hops-config": "10.2.0",
Expand Down
40 changes: 39 additions & 1 deletion packages/build-config/sections/module-rules/postcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var hopsConfig = require('hops-config');

var cssLoader = require.resolve('css-loader');
var postcssLoader = require.resolve('postcss-loader');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

var cssLoaderGlobalOptions = {
importLoaders: 1,
Expand All @@ -27,7 +28,44 @@ var postcssLoaderOptions = {
],
};

exports.default = {
exports.build = {
test: /\.css$/,
oneOf: [
{
resourceQuery: /global/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: cssLoader,
options: cssLoaderGlobalOptions,
},
{
loader: postcssLoader,
options: postcssLoaderOptions,
},
],
}),
},
{
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: cssLoader,
options: cssLoaderLocalOptions,
},
{
loader: postcssLoader,
options: postcssLoaderOptions,
},
],
}),
},
],
};

exports.develop = {
test: /\.css$/,
oneOf: [
{
Expand Down
5 changes: 2 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2910,12 +2910,11 @@ extglob@^2.0.4:
snapdragon "^0.8.1"
to-regex "^3.0.1"

extract-text-webpack-plugin@webpack-contrib/extract-text-webpack-plugin#next:
extract-text-webpack-plugin@^4.0.0-alpha.0:
version "4.0.0-beta.0"
resolved "https://codeload.github.com/webpack-contrib/extract-text-webpack-plugin/tar.gz/a63fee296899ffc6e9c7c1a5ec760893c8c60445"
resolved "https://registry.yarnpkg.com/extract-text-webpack-plugin/-/extract-text-webpack-plugin-4.0.0-beta.0.tgz#f7361d7ff430b42961f8d1321ba8c1757b5d4c42"
dependencies:
async "^2.4.1"
glob "^7.1.2"
loader-utils "^1.1.0"
schema-utils "^0.4.5"
webpack-sources "^1.1.0"
Expand Down

0 comments on commit 823b562

Please sign in to comment.