This repository has been archived by the owner on Oct 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
7,136 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,24 @@ | ||
{ | ||
"presets": ["es2015", "react"] | ||
"presets": ["es2015", "react", | ||
[ | ||
"env", | ||
{ | ||
"modules": false, | ||
"targets": { | ||
"browsers": "> 1%", | ||
"uglify": true | ||
}, | ||
"useBuiltIns": true | ||
} | ||
], | ||
], | ||
"plugins": [ | ||
"syntax-dynamic-import", | ||
[ | ||
"transform-class-properties", | ||
{ | ||
"spec": true | ||
} | ||
] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
plugins: | ||
postcss-smart-import: {} | ||
precss: {} | ||
autoprefixer: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Run Rails & Webpack concurrently | ||
# Example file from webpack-rails gem | ||
rails: bundle exec rails server -b 0.0.0.0 | ||
webpack: ./node_modules/.bin/webpack-dev-server --config config/webpack.config.js --host 0.0.0.0 | ||
webpack: ./bin/webpack-dev-server --host 0.0.0.0 | ||
# If you want to test production mode, use this command because the dev server won't run production configuration | ||
# webpack: ./bin/webpack --watch --progress --colors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<div id="app"> | ||
</div> | ||
<%= javascript_include_tag *webpack_asset_paths('landing', extension: 'js') %> | ||
<%= javascript_pack_tag 'landing.js' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env ruby | ||
$stdout.sync = true | ||
|
||
require "shellwords" | ||
require "yaml" | ||
|
||
ENV["RAILS_ENV"] ||= "development" | ||
RAILS_ENV = ENV["RAILS_ENV"] | ||
|
||
ENV["NODE_ENV"] ||= RAILS_ENV | ||
NODE_ENV = ENV["NODE_ENV"] | ||
|
||
APP_PATH = File.expand_path("../", __dir__) | ||
NODE_MODULES_PATH = File.join(APP_PATH, "node_modules") | ||
WEBPACK_CONFIG = File.join(APP_PATH, "config/webpack/#{NODE_ENV}.js") | ||
|
||
unless File.exist?(WEBPACK_CONFIG) | ||
puts "Webpack configuration not found." | ||
puts "Please run bundle exec rails webpacker:install to install webpacker" | ||
exit! | ||
end | ||
|
||
newenv = { "NODE_PATH" => NODE_MODULES_PATH.shellescape } | ||
cmdline = ["yarn", "run", "webpack", "--", "--config", WEBPACK_CONFIG] + ARGV | ||
|
||
Dir.chdir(APP_PATH) do | ||
exec newenv, *cmdline | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env ruby | ||
$stdout.sync = true | ||
|
||
require "shellwords" | ||
require "yaml" | ||
|
||
ENV["RAILS_ENV"] ||= "development" | ||
RAILS_ENV = ENV["RAILS_ENV"] | ||
|
||
ENV["NODE_ENV"] ||= RAILS_ENV | ||
NODE_ENV = ENV["NODE_ENV"] | ||
|
||
APP_PATH = File.expand_path("../", __dir__) | ||
CONFIG_FILE = File.join(APP_PATH, "config/webpacker.yml") | ||
NODE_MODULES_PATH = File.join(APP_PATH, "node_modules") | ||
WEBPACK_CONFIG = File.join(APP_PATH, "config/webpack/development.js") | ||
|
||
def args(key) | ||
index = ARGV.index(key) | ||
index ? ARGV[index + 1] : nil | ||
end | ||
|
||
begin | ||
dev_server = YAML.load_file(CONFIG_FILE)["development"]["dev_server"] | ||
|
||
DEV_SERVER_HOST = "http#{"s" if args('--https') || dev_server["https"]}://#{args('--host') || dev_server["host"]}:#{args('--port') || dev_server["port"]}" | ||
|
||
rescue Errno::ENOENT, NoMethodError | ||
puts "Webpack dev_server configuration not found in #{CONFIG_FILE}." | ||
puts "Please run bundle exec rails webpacker:install to install webpacker" | ||
exit! | ||
end | ||
|
||
newenv = { | ||
"NODE_PATH" => NODE_MODULES_PATH.shellescape, | ||
"ASSET_HOST" => DEV_SERVER_HOST.shellescape | ||
}.freeze | ||
|
||
cmdline = ["yarn", "run", "webpack-dev-server", "--", "--progress", "--color", "--config", WEBPACK_CONFIG] + ARGV | ||
|
||
Dir.chdir(APP_PATH) do | ||
exec newenv, *cmdline | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Common configuration for webpacker loaded from config/webpacker.yml | ||
'use strict'; | ||
|
||
const { env } = require('process'); | ||
const { safeLoad } = require('js-yaml'); | ||
const { readFileSync } = require('fs'); | ||
const { join, resolve } = require('path'); | ||
|
||
const configPath = resolve('config', 'webpacker.yml'); | ||
const loadersDir = join(__dirname, 'loaders'); | ||
const settings = safeLoad(readFileSync(configPath), 'utf8')[env.NODE_ENV]; | ||
|
||
function removeOuterSlashes(string) { | ||
return string.replace(/^\/*/, '').replace(/\/*$/, ''); | ||
} | ||
|
||
function formatPublicPath(host = '', path = '') { | ||
let formattedHost = removeOuterSlashes(host); | ||
if (formattedHost && !/^http/i.test(formattedHost)) { | ||
formattedHost = `//${formattedHost}`; | ||
} | ||
const formattedPath = removeOuterSlashes(path); | ||
return `${formattedHost}/${formattedPath}/`; | ||
} | ||
|
||
const output = { | ||
path: resolve('public', settings.public_output_path), | ||
publicPath: formatPublicPath(env.ASSET_HOST, settings.public_output_path) | ||
}; | ||
|
||
// Setting this in development.js doesn't work for some reason? | ||
if (process.env.NODE_ENV !== 'production'){ | ||
output.publicPath = 'http://' + settings.dev_server.host + ':' + settings.dev_server.port + '/webpack/'; | ||
} | ||
|
||
module.exports = { | ||
settings, | ||
env, | ||
loadersDir, | ||
output | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Note: You must restart bin/webpack-dev-server for changes to take effect | ||
'use strict'; | ||
|
||
const merge = require('webpack-merge'); | ||
const sharedConfig = require('./shared.js'); | ||
const { settings, output } = require('./configuration.js'); | ||
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); | ||
|
||
module.exports = merge(sharedConfig, { | ||
entry: { | ||
// Sources are expected to live in $app_root/webpack | ||
'babel-polyfill': 'babel-polyfill', | ||
'landing': './webpack/landing.js' | ||
}, | ||
|
||
devtool: 'cheap-eval-source-map', | ||
|
||
stats: { | ||
errorDetails: true | ||
}, | ||
|
||
plugins: [ | ||
new BundleAnalyzerPlugin() | ||
], | ||
|
||
output: { | ||
pathinfo: true | ||
}, | ||
|
||
devServer: { | ||
clientLogLevel: 'none', | ||
https: settings.dev_server.https, | ||
host: settings.dev_server.host, | ||
port: settings.dev_server.port, | ||
contentBase: output.path, | ||
publicPath: output.publicPath, | ||
compress: true, | ||
headers: { 'Access-Control-Allow-Origin': '*' }, | ||
historyApiFallback: true, | ||
watchOptions: { | ||
ignored: /node_modules/ | ||
} | ||
} | ||
}); |
Oops, something went wrong.