Skip to content
This repository was archived by the owner on Jun 3, 2019. It is now read-only.

Commit 3342626

Browse files
committed
Use mini-css-extract instead of extract-text-plugin
1 parent 2c80f0a commit 3342626

File tree

5 files changed

+46
-43
lines changed

5 files changed

+46
-43
lines changed

internal/webpack/configFactory.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import appRootDir from 'app-root-dir';
22
import AssetsPlugin from 'assets-webpack-plugin';
3-
import ExtractTextPlugin from 'extract-text-webpack-plugin';
3+
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
44
import UglifyJsPlugin from 'uglifyjs-webpack-plugin';
55
import nodeExternals from 'webpack-node-externals';
66
import path from 'path';
@@ -66,6 +66,9 @@ export default function webpackConfigFactory(buildOptions) {
6666
let webpackConfig = {
6767
// Webpack Mode
6868
mode: ifDev('development', 'production'),
69+
// Add context for resolving entry points and loaders from configuration
70+
// it is recommended to define the context
71+
context: appRootDir.get(),
6972
// Define our entry chunks for our bundle.
7073
entry: {
7174
// We name our entry files "index" as it makes it easier for us to
@@ -331,9 +334,9 @@ export default function webpackConfigFactory(buildOptions) {
331334
// CSS files.
332335
ifProdClient(
333336
() =>
334-
new ExtractTextPlugin({
335-
filename: '[name]-[contenthash].css',
336-
allChunks: true,
337+
new MiniCssExtractPlugin({
338+
filename: '[name]-[chunkhash].css',
339+
chunkFilename: '[name]-[chunkhash].css',
337340
}),
338341
),
339342

@@ -484,16 +487,13 @@ export default function webpackConfigFactory(buildOptions) {
484487
// an ExtractTextPlugin instance.
485488
// Note: The ExtractTextPlugin needs to be registered within the
486489
// plugins section too.
487-
ifProdClient(() => ({
488-
loader: ExtractTextPlugin.extract({
489-
fallback: 'style-loader',
490-
use: ['css-loader'],
491-
}),
492-
})),
490+
ifProdClient({
491+
use: [MiniCssExtractPlugin.loader, 'css-loader'],
492+
}),
493493
// When targetting the server we use the "/locals" version of the
494494
// css loader, as we don't need any css files for the server.
495495
ifNode({
496-
loaders: ['css-loader/locals'],
496+
use: ['css-loader/locals'],
497497
}),
498498
),
499499
),

package-lock.json

Lines changed: 27 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@
111111
"eslint-plugin-import": "2.9.0",
112112
"eslint-plugin-jsx-a11y": "6.0.3",
113113
"eslint-plugin-react": "7.7.0",
114-
"extract-text-webpack-plugin": "4.0.0-beta.0",
115114
"file-loader": "1.1.11",
116115
"glob": "7.1.2",
117116
"happypack": "5.0.0-beta.1",
@@ -122,6 +121,7 @@
122121
"jest": "22.4.2",
123122
"lint-staged": "7.0.0",
124123
"md5": "2.2.1",
124+
"mini-css-extract-plugin": "0.2.0",
125125
"modernizr-loader": "1.0.1",
126126
"node-notifier": "5.2.1",
127127
"prettier": "1.11.1",
@@ -133,7 +133,7 @@
133133
"request": "2.85.0",
134134
"rimraf": "2.6.2",
135135
"semver": "5.5.0",
136-
"source-map-support": "0.5.3",
136+
"source-map-support": "0.5.4",
137137
"style-loader": "0.20.3",
138138
"webpack": "4.1.1",
139139
"webpack-bundle-analyzer": "2.11.1",

shared/components/DemoApp/AsyncCounterRoute/CounterRoute.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/* eslint-disable react/no-unescaped-entities */
22
import React, { Component } from 'react';
33

4+
import './styles.css';
5+
46
class CounterRoute extends Component {
57
constructor(props) {
68
super(props);
@@ -15,7 +17,7 @@ class CounterRoute extends Component {
1517
render() {
1618
return (
1719
<div>
18-
<h3>Counter</h3>
20+
<h3 className="counter__title">Counter</h3>
1921
<p>
2022
<em>
2123
This is a small demo component that contains state. It's useful for
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.counter__title {
2+
color: green;
3+
}

0 commit comments

Comments
 (0)