Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
10deca82
Commit
10deca82
authored
Apr 12, 2017
by
Mike Greiling
Committed by
Alfredo Sumaran
Apr 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve webpack-dev-server compatibility with non-localhost setups.
parent
c68ea29d
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
8 deletions
+45
-8
app/helpers/javascript_helper.rb
app/helpers/javascript_helper.rb
+3
-2
app/helpers/webpack_helper.rb
app/helpers/webpack_helper.rb
+30
-0
app/views/layouts/_head.html.haml
app/views/layouts/_head.html.haml
+3
-3
changelogs/unreleased/27729-improve-webpack-dev-environment.yml
...logs/unreleased/27729-improve-webpack-dev-environment.yml
+4
-0
config/webpack.config.js
config/webpack.config.js
+3
-1
doc/development/fe_guide/performance.md
doc/development/fe_guide/performance.md
+2
-2
No files found.
app/helpers/javascript_helper.rb
View file @
10deca82
...
...
@@ -3,7 +3,8 @@ module JavascriptHelper
javascript_include_tag
asset_path
(
js
)
end
def
page_specific_javascript_bundle_tag
(
js
)
javascript_include_tag
(
*
webpack_asset_paths
(
js
))
# deprecated; use webpack_bundle_tag directly instead
def
page_specific_javascript_bundle_tag
(
bundle
)
webpack_bundle_tag
(
bundle
)
end
end
app/helpers/webpack_helper.rb
0 → 100644
View file @
10deca82
require
'webpack/rails/manifest'
module
WebpackHelper
def
webpack_bundle_tag
(
bundle
)
javascript_include_tag
(
*
gitlab_webpack_asset_paths
(
bundle
))
end
# override webpack-rails gem helper until changes can make it upstream
def
gitlab_webpack_asset_paths
(
source
,
extension:
nil
)
return
""
unless
source
.
present?
paths
=
Webpack
::
Rails
::
Manifest
.
asset_paths
(
source
)
if
extension
paths
=
paths
.
select
{
|
p
|
p
.
ends_with?
".
#{
extension
}
"
}
end
# include full webpack-dev-server url for rspec tests running locally
if
Rails
.
env
.
test?
&&
Rails
.
configuration
.
webpack
.
dev_server
.
enabled
host
=
Rails
.
configuration
.
webpack
.
dev_server
.
host
port
=
Rails
.
configuration
.
webpack
.
dev_server
.
port
protocol
=
Rails
.
configuration
.
webpack
.
dev_server
.
https
?
'https'
:
'http'
paths
.
map!
do
|
p
|
"
#{
protocol
}
://
#{
host
}
:
#{
port
}#{
p
}
"
end
end
paths
end
end
app/views/layouts/_head.html.haml
View file @
10deca82
...
...
@@ -28,9 +28,9 @@
=
stylesheet_link_tag
"application"
,
media:
"all"
=
stylesheet_link_tag
"print"
,
media:
"print"
=
javascript_include_tag
(
*
webpack_asset_paths
(
"runtime"
))
=
javascript_include_tag
(
*
webpack_asset_paths
(
"common"
))
=
javascript_include_tag
(
*
webpack_asset_paths
(
"main"
))
=
webpack_bundle_tag
"runtime"
=
webpack_bundle_tag
"common"
=
webpack_bundle_tag
"main"
-
if
content_for?
(
:page_specific_javascripts
)
=
yield
:page_specific_javascripts
...
...
changelogs/unreleased/27729-improve-webpack-dev-environment.yml
0 → 100644
View file @
10deca82
---
title
:
Add webpack_bundle_tag helper to improve non-localhost GDK configurations
merge_request
:
10604
author
:
config/webpack.config.js
View file @
10deca82
...
...
@@ -11,6 +11,7 @@ var WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeMod
var
ROOT_PATH
=
path
.
resolve
(
__dirname
,
'
..
'
);
var
IS_PRODUCTION
=
process
.
env
.
NODE_ENV
===
'
production
'
;
var
IS_DEV_SERVER
=
process
.
argv
[
1
].
indexOf
(
'
webpack-dev-server
'
)
!==
-
1
;
var
DEV_SERVER_HOST
=
process
.
env
.
DEV_SERVER_HOST
||
'
localhost
'
;
var
DEV_SERVER_PORT
=
parseInt
(
process
.
env
.
DEV_SERVER_PORT
,
10
)
||
3808
;
var
DEV_SERVER_LIVERELOAD
=
process
.
env
.
DEV_SERVER_LIVERELOAD
!==
'
false
'
;
var
WEBPACK_REPORT
=
process
.
env
.
WEBPACK_REPORT
;
...
...
@@ -182,12 +183,13 @@ if (IS_PRODUCTION) {
if
(
IS_DEV_SERVER
)
{
config
.
devtool
=
'
cheap-module-eval-source-map
'
;
config
.
devServer
=
{
host
:
DEV_SERVER_HOST
,
port
:
DEV_SERVER_PORT
,
headers
:
{
'
Access-Control-Allow-Origin
'
:
'
*
'
},
stats
:
'
errors-only
'
,
inline
:
DEV_SERVER_LIVERELOAD
};
config
.
output
.
publicPath
=
'
//
localhost
:
'
+
DEV_SERVER_PORT
+
config
.
output
.
publicPath
;
config
.
output
.
publicPath
=
'
//
'
+
DEV_SERVER_HOST
+
'
:
'
+
DEV_SERVER_PORT
+
config
.
output
.
publicPath
;
config
.
plugins
.
push
(
// watch node_modules for changes if we encounter a missing module compile error
new
WatchMissingNodeModulesPlugin
(
path
.
join
(
ROOT_PATH
,
'
node_modules
'
))
...
...
doc/development/fe_guide/performance.md
View file @
10deca82
...
...
@@ -48,8 +48,8 @@ Steps to split page-specific JavaScript from the main `main.js`:
```
haml
-
content_for
:page_specific_javascripts
do
=
page_specific_javascript_bundle_tag
(
'lib_chart'
)
=
page_specific_javascript_bundle_tag
(
'graphs'
)
=
webpack_bundle_tag
'lib_chart'
=
webpack_bundle_tag
'graphs'
```
The above loads
`chart.js`
and
`graphs_bundle.js`
for this page only.
`chart.js`
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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