Skip to content
This repository was archived by the owner on Oct 24, 2022. It is now read-only.

Commit 0d769f9

Browse files
committed
v0.0.1: SASS, External SW, Package name, Template
1 parent e637c79 commit 0d769f9

File tree

8 files changed

+99
-8
lines changed

8 files changed

+99
-8
lines changed

packages/react-scripts/config/webpack.config.dev.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,40 @@ module.exports = {
205205
},
206206
],
207207
},
208+
// SASS Loader
209+
{
210+
test: /\.scss$/,
211+
use: [
212+
require.resolve('style-loader'),
213+
{
214+
loader: require.resolve('css-loader'),
215+
options: {
216+
importLoaders: 1,
217+
},
218+
},
219+
{
220+
loader: require.resolve('postcss-loader'),
221+
options: {
222+
// Necessary for external CSS imports to work
223+
// https://github.com/facebookincubator/create-react-app/issues/2677
224+
ident: 'postcss',
225+
plugins: () => [
226+
require('postcss-flexbugs-fixes'),
227+
autoprefixer({
228+
browsers: [
229+
'>1%',
230+
'last 4 versions',
231+
'Firefox ESR',
232+
'not ie < 9', // React doesn't support IE8 anyway
233+
],
234+
flexbox: 'no-2009',
235+
}),
236+
],
237+
},
238+
},
239+
require.resolve('sass-loader')
240+
],
241+
},
208242
// "file" loader makes sure those assets get served by WebpackDevServer.
209243
// When you `import` an asset, you get its (virtual) filename.
210244
// In production, they would get copied to the `build` folder.

packages/react-scripts/config/webpack.config.prod.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,56 @@ module.exports = {
239239
),
240240
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
241241
},
242+
// SASS Loader
243+
{
244+
test: /\.scss$/,
245+
loader: ExtractTextPlugin.extract(
246+
Object.assign(
247+
{
248+
fallback: require.resolve('style-loader'),
249+
use: [
250+
{
251+
loader: require.resolve('css-loader'),
252+
options: {
253+
importLoaders: 1,
254+
minimize: true,
255+
sourceMap: shouldUseSourceMap,
256+
},
257+
},
258+
{
259+
loader: require.resolve('postcss-loader'),
260+
options: {
261+
// Necessary for external CSS imports to work
262+
// https://github.com/facebookincubator/create-react-app/issues/2677
263+
ident: 'postcss',
264+
plugins: () => [
265+
require('postcss-flexbugs-fixes'),
266+
autoprefixer({
267+
browsers: [
268+
'>1%',
269+
'last 4 versions',
270+
'Firefox ESR',
271+
'not ie < 9', // React doesn't support IE8 anyway
272+
],
273+
flexbox: 'no-2009',
274+
}),
275+
],
276+
sourceMap: shouldUseSourceMap
277+
},
278+
},
279+
{
280+
loader: require.resolve('sass-loader'),
281+
options: {
282+
sourceMap: shouldUseSourceMap
283+
}
284+
}
285+
],
286+
},
287+
extractTextPluginOptions
288+
)
289+
),
290+
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
291+
},
242292
// "file" loader makes sure assets end up in the `build` folder.
243293
// When you `import` an asset, you get its filename.
244294
// This loader doesn't use a "test" so it will catch all modules
@@ -349,6 +399,10 @@ module.exports = {
349399
navigateFallbackWhitelist: [/^(?!\/__).*/],
350400
// Don't precache sourcemaps (they're large) and build asset manifest:
351401
staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/],
402+
// Import custom service worker
403+
importScripts: [
404+
{ filename: publicPath + 'sw-custom.js' }
405+
]
352406
}),
353407
// Moment.js is an extremely popular library that bundles large locale files
354408
// by default due to how Webpack interprets its code. This is a practical

packages/react-scripts/package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
2-
"name": "react-scripts-ts",
3-
"version": "2.8.0",
2+
"name": "flipdish-react-scripts-fork",
3+
"version": "0.0.1",
44
"description": "Configuration and scripts for Create React App.",
5-
"repository": "wmonk/create-react-app",
5+
"repository": "flipdishbytes/flipdish-create-react-app-typescript",
66
"license": "BSD-3-Clause",
77
"engines": {
88
"node": ">=6"
99
},
1010
"bugs": {
11-
"url": "https://github.com/wmonk/create-react-app/issues"
11+
"url": "https://github.com/flipdishbytes/flipdish-create-react-app-typescript"
1212
},
1313
"files": [
1414
"bin",
@@ -32,21 +32,23 @@
3232
"fs-extra": "3.0.1",
3333
"html-webpack-plugin": "2.29.0",
3434
"jest": "20.0.4",
35+
"node-sass": "^4.7.2",
3536
"object-assign": "4.1.1",
3637
"postcss-flexbugs-fixes": "3.2.0",
3738
"postcss-loader": "2.0.8",
3839
"promise": "8.0.1",
3940
"raf": "3.4.0",
4041
"react-dev-utils": "4.2.1",
42+
"sass-loader": "^6.0.6",
43+
"source-map-loader": "^0.2.1",
4144
"style-loader": "0.19.0",
45+
"sw-precache-webpack-plugin": "0.11.4",
4246
"ts-jest": "^20.0.7",
4347
"ts-loader": "^2.3.7",
4448
"tslint": "^5.7.0",
4549
"tslint-loader": "^3.5.3",
4650
"tslint-react": "^3.2.0",
4751
"typescript": "~2.5.3",
48-
"source-map-loader": "^0.2.1",
49-
"sw-precache-webpack-plugin": "0.11.4",
5052
"url-loader": "0.6.2",
5153
"webpack": "3.8.1",
5254
"webpack-dev-server": "2.9.4",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('External service worker loaded');

packages/react-scripts/template/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import './App.css';
2+
import './App.scss';
33

44
const logo = require('./logo.svg');
55

packages/react-scripts/template/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import * as ReactDOM from 'react-dom';
33
import App from './App';
44
import registerServiceWorker from './registerServiceWorker';
5-
import './index.css';
5+
import './index.scss';
66

77
ReactDOM.render(
88
<App />,

0 commit comments

Comments
 (0)