Skip to content

Commit 05aa93b

Browse files
committed
supported stylus, css modules, common path alias
1 parent 735966d commit 05aa93b

File tree

5 files changed

+5564
-34
lines changed

5 files changed

+5564
-34
lines changed

packages/react-scripts/config/paths.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -116,25 +116,3 @@ module.exports = {
116116

117117
var reactScriptsPath = path.resolve('node_modules/react-scripts');
118118
var reactScriptsLinked = fs.existsSync(reactScriptsPath) && fs.lstatSync(reactScriptsPath).isSymbolicLink();
119-
120-
// config before publish: we're in ./packages/react-scripts/config/
121-
if (!reactScriptsLinked && __dirname.indexOf(path.join('packages', 'react-scripts', 'config')) !== -1) {
122-
module.exports = {
123-
appPath: resolveApp('.'),
124-
ownPath: resolveOwn('.'),
125-
appBuild: resolveOwn('../../build'),
126-
appPublic: resolveOwn('template/public'),
127-
appHtml: resolveOwn('template/public/index.html'),
128-
appIndexJs: resolveOwn('template/src/index.js'),
129-
appPackageJson: resolveOwn('package.json'),
130-
appSrc: resolveOwn('template/src'),
131-
yarnLockFile: resolveOwn('template/yarn.lock'),
132-
testsSetup: resolveOwn('template/src/setupTests.js'),
133-
appNodeModules: resolveOwn('node_modules'),
134-
ownNodeModules: resolveOwn('node_modules'),
135-
nodePaths: nodePaths,
136-
publicUrl: getPublicUrl(resolveOwn('package.json')),
137-
servedPath: getServedPath(resolveOwn('package.json'))
138-
};
139-
}
140-
// @remove-on-eject-end

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,17 @@ module.exports = {
8181
// We placed these paths second because we want `node_modules` to "win"
8282
// if there are any conflicts. This matches Node resolution mechanism.
8383
// https://github.com/facebookincubator/create-react-app/issues/253
84-
modules: ['node_modules'].concat(paths.nodePaths).concat(paths.appSrc),
84+
modules: ['node_modules'].concat(paths.nodePaths),
8585
// These are the reasonable defaults supported by the Node ecosystem.
8686
// We also include JSX as a common component filename extension to support
8787
// some tools, although we do not recommend using it, see:
8888
// https://github.com/facebookincubator/create-react-app/issues/290
89-
extensions: ['.js', '.json', '.jsx'],
89+
extensions: ['.js', '.json', '.jsx', 'styl'],
9090
alias: {
9191
// Support React Native Web
9292
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
93-
'react-native': 'react-native-web'
93+
'react-native': 'react-native-web',
94+
'common': path.resolve(paths.appSrc, 'common'),
9495
}
9596
},
9697
// @remove-on-eject-begin
@@ -137,7 +138,7 @@ module.exports = {
137138
exclude: [
138139
/\.html$/,
139140
/\.(js|jsx)$/,
140-
/\.css$/,
141+
/\.styl$/,
141142
/\.json$/,
142143
/\.svg$/
143144
],
@@ -169,12 +170,14 @@ module.exports = {
169170
// In production, we use a plugin to extract that CSS to a file, but
170171
// in development "style" loader enables hot editing of CSS.
171172
{
172-
test: /\.css$/,
173+
test: /\.styl$/,
173174
use: [
174175
'style-loader', {
175176
loader: 'css-loader',
176177
options: {
177-
importLoaders: 1
178+
importLoaders: 2,
179+
modules: true,
180+
localIdentName: '[path]-[name]-[local]-[hash:base64:4]',
178181
}
179182
}, {
180183
loader: 'postcss-loader',
@@ -193,6 +196,8 @@ module.exports = {
193196
]
194197
}
195198
}
199+
}, {
200+
loader: 'stylus-loader'
196201
}
197202
]
198203
},

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,12 @@ module.exports = {
9191
// We also include JSX as a common component filename extension to support
9292
// some tools, although we do not recommend using it, see:
9393
// https://github.com/facebookincubator/create-react-app/issues/290
94-
extensions: ['.js', '.json', '.jsx'],
94+
extensions: ['.js', '.json', '.jsx', 'styl'],
9595
alias: {
9696
// Support React Native Web
9797
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
98-
'react-native': 'react-native-web'
98+
'react-native': 'react-native-web',
99+
'common': path.resolve(paths.appSrc, 'common'),
99100
}
100101
},
101102
// @remove-on-eject-begin
@@ -144,7 +145,7 @@ module.exports = {
144145
exclude: [
145146
/\.html$/,
146147
/\.(js|jsx)$/,
147-
/\.css$/,
148+
/\.styl$/,
148149
/\.json$/,
149150
/\.svg$/
150151
],
@@ -179,14 +180,16 @@ module.exports = {
179180
// use the "style" loader inside the async code so CSS from them won't be
180181
// in the main CSS file.
181182
{
182-
test: /\.css$/,
183+
test: /\.styl$/,
183184
loader: ExtractTextPlugin.extract(Object.assign({
184185
fallback: 'style-loader',
185186
use: [
186187
{
187188
loader: 'css-loader',
188189
options: {
189-
importLoaders: 1
190+
importLoaders: 2,
191+
modules: true,
192+
localIdentName: '[hash:base64:6]',
190193
}
191194
}, {
192195
loader: 'postcss-loader',
@@ -205,6 +208,8 @@ module.exports = {
205208
]
206209
}
207210
}
211+
}, {
212+
loader: 'stylus-loader'
208213
}
209214
]
210215
}, extractTextPluginOptions))

packages/react-scripts/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sero.ai-react-scripts",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Configuration and scripts for Create React App. Customized for sero.ai team.",
55
"repository": "Qrysto/create-react-app",
66
"license": "BSD-3-Clause",
@@ -59,6 +59,8 @@
5959
"recursive-readdir": "2.1.1",
6060
"strip-ansi": "3.0.1",
6161
"style-loader": "0.13.1",
62+
"stylus": "^0.54.5",
63+
"stylus-loader": "^2.5.0",
6264
"url-loader": "0.5.7",
6365
"webpack": "2.2.1",
6466
"webpack-dev-server": "2.4.1",

0 commit comments

Comments
 (0)