From ad14c1a76f215ff13eb9d2f67acdbdfbcab08ebe Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Wed, 24 May 2017 13:17:34 +0100 Subject: [PATCH] Minor babelrc and sourcemap update --- CHANGELOG.md | 34 +++++++++++++++++++++- lib/install/config/.babelrc | 5 ++++ lib/install/config/webpack/production.js | 16 +++++++++- lib/install/examples/angular/tsconfig.json | 1 + lib/install/template.rb | 15 ++++------ 5 files changed, 60 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 768da276a..099357ac3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## [Unreleased] + ### Fixed - Update `.babelrc` to fix compilation issues - [#306](https://github.com/rails/webpacker/issues/306) @@ -13,6 +14,7 @@ - ARGV support for `webpack-dev-server` - [#286](https://github.com/rails/webpacker/issues/286) + ### Added - [Elm](http://elm-lang.org) support. You can now add Elm support via the following methods: - New app: `rails new --webpack=elm` @@ -30,9 +32,33 @@ source_entry_path: packs public_output_path: sweet/js ``` - + - `https` option to use `https` mode, particularly on platforms like - https://community.c9.io/t/running-a-rails-app/1615 or locally - [#176](https://github.com/rails/webpacker/issues/176) +- [Babel] Dynamic import() and Class Fields and Static Properties babel plugin to `.babelrc` + +```json +{ + "presets": [ + ["env", { + "modules": false, + "targets": { + "browsers": "> 1%", + "uglify": true + }, + "useBuiltIns": true + }] + ], + + "plugins": [ + "syntax-dynamic-import", + "transform-class-properties", { "spec": true } + ] +} +``` + +- Source-map support for production bundle + #### Breaking Change @@ -57,6 +83,7 @@ bundle update webpacker bundle exec rails webpacker:install ``` + ### Fixed - Support Spring - [#205](https://github.com/rails/webpacker/issues/205) @@ -75,6 +102,7 @@ bundle exec rails webpacker:install - Move babel presets and plugins to .babelrc - [#202](https://github.com/rails/webpacker/issues/202) + ### Added - A changelog - [#211](https://github.com/rails/webpacker/issues/211) - Minimize CSS assets - [#218](https://github.com/rails/webpacker/issues/218) @@ -91,9 +119,11 @@ bundle exec rails webpacker:install - Add initial test case by @kimquy [#259](https://github.com/rails/webpacker/pull/259) - Compile assets before test:controllers and test:system + ### Removed - Webpack watcher - [#295](https://github.com/rails/webpacker/pull/295) + ## [1.1] - 2017-03-24 This release requires you to run below commands to install new features. @@ -101,6 +131,7 @@ This release requires you to run below commands to install new features. ``` bundle update webpacker bundle exec rails webpacker:install + # if installed react, vue or angular bundle exec rails webpacker:install:[react, angular, vue] ``` @@ -109,6 +140,7 @@ bundle exec rails webpacker:install:[react, angular, vue] - Static assets support - [#153](https://github.com/rails/webpacker/pull/153) - Advanced webpack configuration - [#153](https://github.com/rails/webpacker/pull/153) + ### Removed ```rb diff --git a/lib/install/config/.babelrc b/lib/install/config/.babelrc index 67bea12e8..e7a28d6fe 100644 --- a/lib/install/config/.babelrc +++ b/lib/install/config/.babelrc @@ -8,5 +8,10 @@ }, "useBuiltIns": true }] + ], + + "plugins": [ + "syntax-dynamic-import", + ["transform-class-properties", { "spec": true }] ] } diff --git a/lib/install/config/webpack/production.js b/lib/install/config/webpack/production.js index bc93f96b3..b814cceb7 100644 --- a/lib/install/config/webpack/production.js +++ b/lib/install/config/webpack/production.js @@ -9,9 +9,23 @@ const sharedConfig = require('./shared.js') module.exports = merge(sharedConfig, { output: { filename: '[name]-[chunkhash].js' }, + devtool: 'source-map', + stats: 'normal', plugins: [ - new webpack.optimize.UglifyJsPlugin(), + new webpack.optimize.UglifyJsPlugin({ + minimize: true, + sourceMap: true, + + compress: { + warnings: false + }, + + output: { + comments: false + } + }), + new CompressionPlugin({ asset: '[path].gz[query]', algorithm: 'gzip', diff --git a/lib/install/examples/angular/tsconfig.json b/lib/install/examples/angular/tsconfig.json index d86a6341a..73dc7aa57 100644 --- a/lib/install/examples/angular/tsconfig.json +++ b/lib/install/examples/angular/tsconfig.json @@ -12,6 +12,7 @@ "exclude": [ "**/*.spec.ts", "node_modules", + "vendor", "public" ], "compileOnSave": false diff --git a/lib/install/template.rb b/lib/install/template.rb index 73fd6487b..9f178f94c 100644 --- a/lib/install/template.rb +++ b/lib/install/template.rb @@ -5,15 +5,11 @@ directory "#{__dir__}/config/webpack", "config/webpack" directory "#{__dir__}/config/loaders/core", "config/webpack/loaders" -unless File.exist?(".postcssrc.yml") - puts "Copying .postcssrc.yml to app root directory" - copy_file "#{__dir__}/config/.postcssrc.yml", ".postcssrc.yml" -end +puts "Copying .postcssrc.yml to app root directory" +copy_file "#{__dir__}/config/.postcssrc.yml", ".postcssrc.yml" -unless File.exist?(".babelrc") - puts "Copying .babelrc to app root directory" - copy_file "#{__dir__}/config/.babelrc", ".babelrc" -end +puts "Copying .babelrc to app root directory" +copy_file "#{__dir__}/config/.babelrc", ".babelrc" puts "Creating javascript app source directory" directory "#{__dir__}/javascript", "#{Webpacker::Configuration.source}" @@ -35,7 +31,8 @@ "webpack-manifest-plugin babel-loader@7.x coffee-loader coffee-script " \ "babel-core babel-preset-env babel-polyfill compression-webpack-plugin rails-erb-loader glob " \ "extract-text-webpack-plugin node-sass file-loader sass-loader css-loader style-loader " \ -"postcss-loader autoprefixer postcss-smart-import precss resolve-url-loader" +"postcss-loader autoprefixer postcss-smart-import precss resolve-url-loader " \ +"babel-plugin-syntax-dynamic-import babel-plugin-transform-class-properties" puts "Installing dev server for live reloading" run "yarn add --dev webpack-dev-server"