Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Meta
create-react-app
Commits
f05cba5e
Commit
f05cba5e
authored
8 years ago
by
Dan Abramov
Committed by
GitHub
8 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Use /static paths for assets (#278)
* Use /static paths for assets * Fix e2e test
parent
d2baa3c4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
config/webpack.config.dev.js
+10
-3
config/webpack.config.dev.js
config/webpack.config.prod.js
+9
-5
config/webpack.config.prod.js
scripts/build.js
+16
-4
scripts/build.js
tasks/e2e.sh
+9
-3
tasks/e2e.sh
with
44 additions
and
15 deletions
+44
-15
config/webpack.config.dev.js
+
10
-
3
View file @
f05cba5e
...
...
@@ -16,7 +16,7 @@ var paths = require('./paths');
module
.
exports
=
{
devtool
:
'
eval
'
,
entry
:
[
require
.
resolve
(
'
webpack-dev-server/client
'
),
require
.
resolve
(
'
webpack-dev-server/client
'
)
+
'
?/
'
,
require
.
resolve
(
'
webpack/hot/dev-server
'
),
require
.
resolve
(
'
./polyfills
'
),
path
.
join
(
paths
.
appSrc
,
'
index
'
)
...
...
@@ -25,7 +25,7 @@ module.exports = {
// Next line is not used in dev but WebpackDevServer crashes without it:
path
:
paths
.
appBuild
,
pathinfo
:
true
,
filename
:
'
bundle.js
'
,
filename
:
'
static/js/
bundle.js
'
,
publicPath
:
'
/
'
},
resolve
:
{
...
...
@@ -75,11 +75,18 @@ module.exports = {
test
:
/
\.(
jpg|png|gif|eot|svg|ttf|woff|woff2
)
$/
,
include
:
[
paths
.
appSrc
,
paths
.
appNodeModules
],
loader
:
'
file
'
,
query
:
{
name
:
'
static/media/[name].[ext]
'
}
},
{
test
:
/
\.(
mp4|webm
)
$/
,
include
:
[
paths
.
appSrc
,
paths
.
appNodeModules
],
loader
:
'
url?limit=10000
'
loader
:
'
url
'
,
query
:
{
limit
:
10000
,
name
:
'
static/media/[name].[ext]
'
}
}
]
},
...
...
This diff is collapsed.
Click to expand it.
config/webpack.config.prod.js
+
9
-
5
View file @
f05cba5e
...
...
@@ -31,8 +31,8 @@ module.exports = {
],
output
:
{
path
:
paths
.
appBuild
,
filename
:
'
[name].[chunkhash:8].js
'
,
chunkFilename
:
'
[name].[chunkhash:8].chunk.js
'
,
filename
:
'
static/js/
[name].[chunkhash:8].js
'
,
chunkFilename
:
'
static/js/
[name].[chunkhash:8].chunk.js
'
,
publicPath
:
publicPath
},
resolve
:
{
...
...
@@ -86,13 +86,17 @@ module.exports = {
include
:
[
paths
.
appSrc
,
paths
.
appNodeModules
],
loader
:
'
file
'
,
query
:
{
name
:
'
[name].[hash:8].[ext]
'
name
:
'
static/media/
[name].[hash:8].[ext]
'
}
},
{
test
:
/
\.(
mp4|webm
)
$/
,
include
:
[
paths
.
appSrc
,
paths
.
appNodeModules
],
loader
:
'
url?limit=10000
'
loader
:
'
url
'
,
query
:
{
limit
:
10000
,
name
:
'
static/media/[name].[hash:8].[ext]
'
}
}
]
},
...
...
@@ -139,6 +143,6 @@ module.exports = {
screw_ie8
:
true
}
}),
new
ExtractTextPlugin
(
'
[name].[contenthash:8].css
'
)
new
ExtractTextPlugin
(
'
static/css/
[name].[contenthash:8].css
'
)
]
};
This diff is collapsed.
Click to expand it.
scripts/build.js
+
16
-
4
View file @
f05cba5e
...
...
@@ -40,16 +40,28 @@ webpack(config).run(function(err, stats) {
.
filter
(
asset
=>
/
\.(
js|css
)
$/
.
test
(
asset
.
name
))
.
map
(
asset
=>
{
var
fileContents
=
fs
.
readFileSync
(
paths
.
appBuild
+
'
/
'
+
asset
.
name
);
var
size
=
gzipSize
(
fileContents
);
return
{
name
:
asset
.
name
,
size
:
gzipSize
(
fileContents
)
folder
:
path
.
join
(
'
build
'
,
path
.
dirname
(
asset
.
name
)),
name
:
path
.
basename
(
asset
.
name
),
size
:
size
,
sizeLabel
:
filesize
(
size
)
};
});
assets
.
sort
((
a
,
b
)
=>
b
.
size
-
a
.
size
);
var
longestSizeLabelLength
=
Math
.
max
.
apply
(
null
,
assets
.
map
(
a
=>
a
.
sizeLabel
.
length
)
);
assets
.
forEach
(
asset
=>
{
var
sizeLabel
=
asset
.
sizeLabel
;
if
(
sizeLabel
.
length
<
longestSizeLabelLength
)
{
var
rightPadding
=
'
'
.
repeat
(
longestSizeLabelLength
-
sizeLabel
.
length
);
sizeLabel
+=
rightPadding
;
}
console
.
log
(
'
'
+
chalk
.
dim
(
'
build
'
+
path
.
sep
)
+
chalk
.
cyan
(
asset
.
name
)
+
'
:
'
+
chalk
.
green
(
filesize
(
asset
.
siz
e
)
)
'
'
+
chalk
.
green
(
sizeLabel
)
+
'
'
+
chalk
.
dim
(
asset
.
folder
+
path
.
sep
)
+
chalk
.
cyan
(
asset
.
nam
e
)
);
});
console
.
log
();
...
...
This diff is collapsed.
Click to expand it.
tasks/e2e.sh
+
9
-
3
View file @
f05cba5e
...
...
@@ -61,7 +61,9 @@ npm run build
# Check for expected output
test
-e
build/
*
.html
test
-e
build/
*
.js
test
-e
build/static/js/
*
.js
test
-e
build/static/css/
*
.css
test
-e
build/static/media/
*
.svg
# Pack CLI
cd
global-cli
...
...
@@ -84,7 +86,9 @@ npm run build
# Check for expected output
test
-e
build/
*
.html
test
-e
build/
*
.js
test
-e
build/static/js/
*
.js
test
-e
build/static/css/
*
.css
test
-e
build/static/media/
*
.svg
# Test the server
npm start
--
--smoke-test
...
...
@@ -95,7 +99,9 @@ npm run build
# Check for expected output
test
-e
build/
*
.html
test
-e
build/
*
.js
test
-e
build/static/js/
*
.js
test
-e
build/static/css/
*
.css
test
-e
build/static/media/
*
.svg
# Test the server
npm start
--
--smoke-test
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment