- Notifications
You must be signed in to change notification settings - Fork 377
update to beta version #474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
update webpack configs
- Loading branch information
commit 2a441a7b1f0496bf54f13516a1bbd49f580fe884
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,8 +1,2 @@ | ||
| # Run Rails without hot reloading (static assets). | ||
| rails: rails s -b 0.0.0.0 | ||
| | ||
| # Build client assets, watching for changes. | ||
| rails-client-assets: rm -rf public/webpack/development || true && bundle exec rake react_on_rails:locale && yarn run build:dev:client | ||
| | ||
| # Build server assets, watching for changes. Remove if not server rendering. | ||
| rails-server-assets: yarn run build:dev:server |
This file contains hidden or 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,18 @@ | ||
| /* eslint no-console:0 */ | ||
| // This file is automatically compiled by Webpack, along with any other files | ||
| // present in this directory. You're encouraged to place your actual application logic in | ||
| // a relevant structure within app/javascript and only use these pack files to reference | ||
| // that code so it'll be compiled. | ||
| // | ||
| // To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate | ||
| // layout file, like app/views/layouts/application.html.erb | ||
| | ||
| | ||
| // Uncomment to copy all static images under ../images to the output folder and reference | ||
| // them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>) | ||
| // or the `imagePath` JavaScript helper below. | ||
| // | ||
| // const images = require.context('../images', true) | ||
| // const imagePath = (name) => images(name, true) | ||
| | ||
| console.log('Hello World from Webpacker') | ||
This file contains hidden or 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,72 @@ | ||
| module.exports = function(api) { | ||
| Member Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. more files from the installer that should get removed... | ||
| var validEnv = ['development', 'test', 'production'] | ||
| var currentEnv = api.env() | ||
| var isDevelopmentEnv = api.env('development') | ||
| var isProductionEnv = api.env('production') | ||
| var isTestEnv = api.env('test') | ||
| | ||
| if (!validEnv.includes(currentEnv)) { | ||
| throw new Error( | ||
| 'Please specify a valid `NODE_ENV` or ' + | ||
| '`BABEL_ENV` environment variables. Valid values are "development", ' + | ||
| '"test", and "production". Instead, received: ' + | ||
| JSON.stringify(currentEnv) + | ||
| '.' | ||
| ) | ||
| } | ||
| | ||
| return { | ||
| presets: [ | ||
| isTestEnv && [ | ||
| '@babel/preset-env', | ||
| { | ||
| targets: { | ||
| node: 'current' | ||
| } | ||
| } | ||
| ], | ||
| (isProductionEnv || isDevelopmentEnv) && [ | ||
| '@babel/preset-env', | ||
| { | ||
| forceAllTransforms: true, | ||
| useBuiltIns: 'entry', | ||
| corejs: 3, | ||
| modules: false, | ||
| exclude: ['transform-typeof-symbol'] | ||
| } | ||
| ] | ||
| ].filter(Boolean), | ||
| plugins: [ | ||
| 'babel-plugin-macros', | ||
| '@babel/plugin-syntax-dynamic-import', | ||
| isTestEnv && 'babel-plugin-dynamic-import-node', | ||
| '@babel/plugin-transform-destructuring', | ||
| [ | ||
| '@babel/plugin-proposal-class-properties', | ||
| { | ||
| loose: true | ||
| } | ||
| ], | ||
| [ | ||
| '@babel/plugin-proposal-object-rest-spread', | ||
| { | ||
| useBuiltIns: true | ||
| } | ||
| ], | ||
| [ | ||
| '@babel/plugin-transform-runtime', | ||
| { | ||
| helpers: false, | ||
| regenerator: true, | ||
| corejs: false | ||
| } | ||
| ], | ||
| [ | ||
| '@babel/plugin-transform-regenerator', | ||
| { | ||
| async: false | ||
| } | ||
| ] | ||
| ].filter(Boolean) | ||
| } | ||
| } | ||
This file contains hidden or 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,18 @@ | ||
| #!/usr/bin/env ruby | ||
| | ||
| ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development" | ||
| ENV["NODE_ENV"] ||= "development" | ||
| | ||
| require "pathname" | ||
| ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", | ||
| Pathname.new(__FILE__).realpath) | ||
| | ||
| require "bundler/setup" | ||
| | ||
| require "webpacker" | ||
| require "webpacker/webpack_runner" | ||
| | ||
| APP_ROOT = File.expand_path("..", __dir__) | ||
| Dir.chdir(APP_ROOT) do | ||
| Webpacker::WebpackRunner.run(ARGV) | ||
| end |
This file contains hidden or 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,18 @@ | ||
| #!/usr/bin/env ruby | ||
| | ||
| ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development" | ||
| ENV["NODE_ENV"] ||= "development" | ||
| | ||
| require "pathname" | ||
| ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", | ||
| Pathname.new(__FILE__).realpath) | ||
| | ||
| require "bundler/setup" | ||
| | ||
| require "webpacker" | ||
| require "webpacker/dev_server_runner" | ||
| | ||
| APP_ROOT = File.expand_path("..", __dir__) | ||
| Dir.chdir(APP_ROOT) do | ||
| Webpacker::DevServerRunner.run(ARGV) | ||
| end |
This file contains hidden or 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,9 @@ | ||
| const { resolve } = require('path'); | ||
| | ||
| module.exports = { | ||
| resolve: { | ||
| alias: { | ||
| Assets: resolve(__dirname, '..', '..', 'client', 'app', 'assets'), | ||
| }, | ||
| }, | ||
| }; |
This file contains hidden or 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,33 @@ | ||
| process.env.NODE_ENV = process.env.NODE_ENV || 'development'; | ||
| | ||
| // We need to compile both our development JS (for serving to the client) and our server JS | ||
| // (for SSR of React components). This is easy enough as we can export arrays of webpack configs. | ||
| const clientEnvironment = require('./webpack.client.rails.build.config'); | ||
| const serverConfig = require('./webpack.server.rails.build.config'); | ||
| | ||
| const optimization = { | ||
| splitChunks: { | ||
| chunks: 'async', | ||
| cacheGroups: { | ||
| vendor: { | ||
| chunks: 'async', | ||
| name: 'vendor', | ||
| test: 'vendor', | ||
| enforce: true, | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
| | ||
| clientEnvironment.splitChunks((config) => Object.assign({}, config, { optimization: optimization })); | ||
| | ||
| const clientConfig = clientEnvironment.toWebpackConfig(); | ||
| | ||
| // For HMR, we need to separate the the client and server webpack configurations | ||
| if (process.env.WEBPACK_DEV_SERVER) { | ||
| module.exports = clientConfig; | ||
| } else if (process.env.SERVER_BUNDLE_ONLY) { | ||
| module.exports = serverConfig; | ||
| } else { | ||
| module.exports = [clientConfig, serverConfig]; | ||
| } |
This file contains hidden or 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,60 @@ | ||
| const { environment } = require('@rails/webpacker'); | ||
| | ||
| const sassResources = ['./client/app/assets/styles/app-variables.scss']; | ||
| const aliasConfig = require('./alias.js'); | ||
| const rules = environment.loaders; | ||
| const fileLoader = rules.get('file'); | ||
| const cssLoader = rules.get('css'); | ||
| const sassLoader = rules.get('sass'); | ||
| const babelLoader = rules.get('babel'); | ||
| const ManifestPlugin = environment.plugins.get('Manifest'); | ||
| const urlFileSizeCutover = 1000; // below 10k, inline, small 1K is to test file loader | ||
| | ||
| // rules | ||
| sassLoader.use.push({ | ||
| loader: 'sass-resources-loader', | ||
| options: { | ||
| resources: sassResources, | ||
| }, | ||
| }); | ||
| | ||
| //adding urlLoader | ||
| const urlLoader = { | ||
| test: /\.(jpe?g|png|gif|ico|woff)$/, | ||
| use: { | ||
| loader: 'url-loader', | ||
| options: { | ||
| limit: urlFileSizeCutover, | ||
| // NO leading slash | ||
| name: 'images/[name]-[hash].[ext]', | ||
| }, | ||
| }, | ||
| }; | ||
| environment.loaders.insert('url', urlLoader, { before: 'file' }); | ||
| | ||
| // changing order of babelLoader | ||
| environment.loaders.insert('babel', babelLoader, { before: 'css' }); | ||
| | ||
| // add aliases to config | ||
| environment.config.merge(aliasConfig); | ||
| | ||
| // modifying modules in css and sass to true, | ||
| cssLoader.use[1].options.modules = true; | ||
| sassLoader.use[1].options.modules = true; | ||
| | ||
| //changing fileLoader to use proper values | ||
| fileLoader.test = /\.(ttf|eot|svg)$/; | ||
| fileLoader.use[0].options = { name: 'images/[name]-[hash].[ext]' }; | ||
| | ||
| // removing extra rules added by webpacker | ||
| rules.delete('nodeModules'); | ||
| rules.delete('moduleCss'); | ||
| rules.delete('moduleSass'); | ||
| | ||
| // plugins | ||
| // adding definePlugin | ||
| | ||
| // manipulating manifestPlugin | ||
| ManifestPlugin.options.writeToFileEmit = true; | ||
| | ||
| module.exports = environment; |
This file contains hidden or 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 hidden or 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,26 @@ | ||
| process.env.NODE_ENV = process.env.NODE_ENV || 'production'; | ||
| | ||
| // We need to compile both our development JS (for serving to the client) and our server JS | ||
| // (for SSR of React components). This is easy enough as we can export arrays of webpack configs. | ||
| const clientEnvironment = require('./webpack.client.rails.build.config'); | ||
| const serverConfig = require('./webpack.server.rails.build.config'); | ||
| | ||
| const optimization = { | ||
| splitChunks: { | ||
| chunks: 'async', | ||
| cacheGroups: { | ||
| vendor: { | ||
| chunks: 'async', | ||
| name: 'vendor', | ||
| test: 'vendor', | ||
| enforce: true, | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
| | ||
| clientEnvironment.splitChunks((config) => Object.assign({}, config, { optimization: optimization })); | ||
| | ||
| const clientConfig = clientEnvironment.toWebpackConfig(); | ||
| | ||
| module.exports = [clientConfig, serverConfig]; |
This file contains hidden or 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,8 @@ | ||
| process.env.NODE_ENV = process.env.NODE_ENV || 'test'; | ||
| | ||
| const clientEnvironment = require('./client'); | ||
| const serverConfig = require('./server'); | ||
| | ||
| const clientConfig = clientEnvironment.toWebpackConfig(); | ||
| | ||
| module.exports = [clientConfig, serverConfig]; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all files in this directory should get removed...stick to your old custom one...
you did not need to run the webpack installer
it was already there...