Skip to content

Commit c91e1ff

Browse files
committed
bundle exec rails webpacker:install
1 parent 8038d71 commit c91e1ff

14 files changed

+7745
-0
lines changed

.browserslistrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
defaults

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,10 @@
3232

3333
# Ignore master key for decrypting credentials and more.
3434
/config/master.key
35+
36+
/public/packs
37+
/public/packs-test
38+
/node_modules
39+
/yarn-error.log
40+
yarn-debug.log*
41+
.yarn-integrity

app/javascript/packs/application.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* eslint no-console:0 */
2+
// This file is automatically compiled by Webpack, along with any other files
3+
// present in this directory. You're encouraged to place your actual application logic in
4+
// a relevant structure within app/javascript and only use these pack files to reference
5+
// that code so it'll be compiled.
6+
//
7+
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
8+
// layout file, like app/views/layouts/application.html.erb
9+
10+
11+
// Uncomment to copy all static images under ../images to the output folder and reference
12+
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
13+
// or the `imagePath` JavaScript helper below.
14+
//
15+
// const images = require.context('../images', true)
16+
// const imagePath = (name) => images(name, true)
17+
18+
console.log('Hello World from Webpacker')

babel.config.js

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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-transform-runtime',
58+
{
59+
helpers: false,
60+
regenerator: true,
61+
corejs: false
62+
}
63+
],
64+
[
65+
'@babel/plugin-transform-regenerator',
66+
{
67+
async: false
68+
}
69+
]
70+
].filter(Boolean)
71+
}
72+
}

bin/webpack

+18
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

+18
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

+5
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

+3
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

+5
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

+5
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

+92
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+
resolved_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

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"dependencies": {
3+
"@rails/webpacker": "5.1.1"
4+
},
5+
"devDependencies": {
6+
"webpack-dev-server": "^3.11.0"
7+
}
8+
}

postcss.config.js

+12
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)