Skip to content

Commit 749b500

Browse files
committed
Run rails webpacker:install
1 parent eb64590 commit 749b500

13 files changed

+7313
-0
lines changed

.browserslistrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
defaults

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,10 @@
2929

3030
# Ignore master key for decrypting credentials and more.
3131
/config/master.key
32+
33+
/public/packs
34+
/public/packs-test
35+
/node_modules
36+
/yarn-error.log
37+
yarn-debug.log*
38+
.yarn-integrity

babel.config.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
module.exports = function(api) {
2+
var validEnv = ['development', 'test', 'production']
3+
var currentEnv = api.env()
4+
var isDevelopmentEnv = api.env('development')
5+
var isProductionEnv = api.env('production')
6+
var isTestEnv = api.env('test')
7+
8+
if (!validEnv.includes(currentEnv)) {
9+
throw new Error(
10+
'Please specify a valid `NODE_ENV` or ' +
11+
'`BABEL_ENV` environment variables. Valid values are "development", ' +
12+
'"test", and "production". Instead, received: ' +
13+
JSON.stringify(currentEnv) +
14+
'.'
15+
)
16+
}
17+
18+
return {
19+
presets: [
20+
isTestEnv && [
21+
'@babel/preset-env',
22+
{
23+
targets: {
24+
node: 'current'
25+
}
26+
}
27+
],
28+
(isProductionEnv || isDevelopmentEnv) && [
29+
'@babel/preset-env',
30+
{
31+
forceAllTransforms: true,
32+
useBuiltIns: 'entry',
33+
corejs: 3,
34+
modules: false,
35+
exclude: ['transform-typeof-symbol']
36+
}
37+
]
38+
].filter(Boolean),
39+
plugins: [
40+
'babel-plugin-macros',
41+
'@babel/plugin-syntax-dynamic-import',
42+
isTestEnv && 'babel-plugin-dynamic-import-node',
43+
'@babel/plugin-transform-destructuring',
44+
[
45+
'@babel/plugin-proposal-class-properties',
46+
{
47+
loose: true
48+
}
49+
],
50+
[
51+
'@babel/plugin-proposal-object-rest-spread',
52+
{
53+
useBuiltIns: true
54+
}
55+
],
56+
[
57+
'@babel/plugin-proposal-private-methods',
58+
{
59+
loose: true
60+
}
61+
],
62+
[
63+
'@babel/plugin-proposal-private-property-in-object',
64+
{
65+
loose: true
66+
}
67+
],
68+
[
69+
'@babel/plugin-transform-runtime',
70+
{
71+
helpers: false
72+
}
73+
],
74+
[
75+
'@babel/plugin-transform-regenerator',
76+
{
77+
async: false
78+
}
79+
]
80+
].filter(Boolean)
81+
}
82+
}

bin/webpack

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env ruby
2+
3+
ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
4+
ENV["NODE_ENV"] ||= "development"
5+
6+
require "pathname"
7+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8+
Pathname.new(__FILE__).realpath)
9+
10+
require "bundler/setup"
11+
12+
require "webpacker"
13+
require "webpacker/webpack_runner"
14+
15+
APP_ROOT = File.expand_path("..", __dir__)
16+
Dir.chdir(APP_ROOT) do
17+
Webpacker::WebpackRunner.run(ARGV)
18+
end

bin/webpack-dev-server

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env ruby
2+
3+
ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
4+
ENV["NODE_ENV"] ||= "development"
5+
6+
require "pathname"
7+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8+
Pathname.new(__FILE__).realpath)
9+
10+
require "bundler/setup"
11+
12+
require "webpacker"
13+
require "webpacker/dev_server_runner"
14+
15+
APP_ROOT = File.expand_path("..", __dir__)
16+
Dir.chdir(APP_ROOT) do
17+
Webpacker::DevServerRunner.run(ARGV)
18+
end

config/webpack/development.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2+
3+
const environment = require('./environment')
4+
5+
module.exports = environment.toWebpackConfig()

config/webpack/environment.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const { environment } = require('@rails/webpacker')
2+
3+
module.exports = environment

config/webpack/production.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
2+
3+
const environment = require('./environment')
4+
5+
module.exports = environment.toWebpackConfig()

config/webpack/test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2+
3+
const environment = require('./environment')
4+
5+
module.exports = environment.toWebpackConfig()

config/webpacker.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Note: You must restart bin/webpack-dev-server for changes to take effect
2+
3+
default: &default
4+
source_path: app/javascript
5+
source_entry_path: packs
6+
public_root_path: public
7+
public_output_path: packs
8+
cache_path: tmp/cache/webpacker
9+
webpack_compile_output: true
10+
11+
# Additional paths webpack should lookup modules
12+
# ['app/assets', 'engine/foo/app/assets']
13+
additional_paths: []
14+
15+
# Reload manifest.json on all requests so we reload latest compiled packs
16+
cache_manifest: false
17+
18+
# Extract and emit a css file
19+
extract_css: false
20+
21+
static_assets_extensions:
22+
- .jpg
23+
- .jpeg
24+
- .png
25+
- .gif
26+
- .tiff
27+
- .ico
28+
- .svg
29+
- .eot
30+
- .otf
31+
- .ttf
32+
- .woff
33+
- .woff2
34+
35+
extensions:
36+
- .mjs
37+
- .js
38+
- .sass
39+
- .scss
40+
- .css
41+
- .module.sass
42+
- .module.scss
43+
- .module.css
44+
- .png
45+
- .svg
46+
- .gif
47+
- .jpeg
48+
- .jpg
49+
50+
development:
51+
<<: *default
52+
compile: true
53+
54+
# Reference: https://webpack.js.org/configuration/dev-server/
55+
dev_server:
56+
https: false
57+
host: localhost
58+
port: 3035
59+
public: localhost:3035
60+
hmr: false
61+
# Inline should be set to true if using HMR
62+
inline: true
63+
overlay: true
64+
compress: true
65+
disable_host_check: true
66+
use_local_ip: false
67+
quiet: false
68+
pretty: false
69+
headers:
70+
'Access-Control-Allow-Origin': '*'
71+
watch_options:
72+
ignored: '**/node_modules/**'
73+
74+
75+
test:
76+
<<: *default
77+
compile: true
78+
79+
# Compile test packs to a separate directory
80+
public_output_path: packs-test
81+
82+
production:
83+
<<: *default
84+
85+
# Production depends on precompilation of packs prior to booting for performance.
86+
compile: false
87+
88+
# Extract and emit a css file
89+
extract_css: true
90+
91+
# Cache manifest.json for performance
92+
cache_manifest: true

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"dependencies": {
3+
"@rails/webpacker": "5.4.3",
4+
"webpack": "^4.46.0",
5+
"webpack-cli": "^3.3.12"
6+
},
7+
"devDependencies": {
8+
"webpack-dev-server": "^3"
9+
}
10+
}

postcss.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
plugins: [
3+
require('postcss-import'),
4+
require('postcss-flexbugs-fixes'),
5+
require('postcss-preset-env')({
6+
autoprefixer: {
7+
flexbox: 'no-2009'
8+
},
9+
stage: 3
10+
})
11+
]
12+
}

0 commit comments

Comments
 (0)