vue_cli-rails 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2601878a76dbcdb50c5cffb4264b53269d192cf1
4
- data.tar.gz: ce5ee501f09e485ad4d37d59af2294261e4102d9
3
+ metadata.gz: c73bc49c1a774fc57b0c9d106af051b7f2a8bda5
4
+ data.tar.gz: 3bd24fe745d33907c86aa1928bb086656eba2a14
5
5
  SHA512:
6
- metadata.gz: fb4d53c1b1479d8a80a4c27debe0e7bd1c93667d3ef2ed7882a52a682fdd50bd57d2e77e3ef64e4208447e9b8eba14665897cfbbd2e5f29c616217bee287b62b
7
- data.tar.gz: c72f12ccf709314f4a4e2885b68185d590fdc18a7bc939de2a051389f77d23aaed7133aa61a3d0b360b0f92f06477efd1847014f958c9fb4750c683028c7ae8e
6
+ metadata.gz: 308ad9d983e729cf74e8ba2f8ae71152f132d1b842f18cb0d3fc1b4d3d3c8ae5d10b5e70e855c31e6a610d5d042dd35efb91e037942ffdd878e77eb11175a76a
7
+ data.tar.gz: 68f2f03b3a3fe0f33f94c2809f25dcbb96681d03b8fe01ab30182cf04b388308a4aea536536acf146acfbc29873534aec850402564fdb347b27519f6e6a3abda
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ *.gem
data/Gemfile.lock CHANGED
@@ -89,7 +89,7 @@ PLATFORMS
89
89
  ruby
90
90
 
91
91
  DEPENDENCIES
92
- bundler (~> 1.16)
92
+ bundler (~> 1.12)
93
93
  pry-byebug
94
94
  rake (~> 10.0)
95
95
  rspec (~> 3.0)
data/README.md CHANGED
@@ -15,8 +15,6 @@ And then execute:
15
15
  $ bundle install
16
16
  $ bundle exec rake vue:create
17
17
 
18
- > Currently `rake vue:create` will overwrite all files, please be careful!
19
-
20
18
  Add those lines to your `config/routes.rb`:
21
19
 
22
20
  ```ruby
@@ -24,6 +22,8 @@ Add those lines to your `config/routes.rb`:
24
22
  get 'vue/bar' => 'vue#bar'
25
23
  ```
26
24
 
25
+ > Currently `rake vue:create` will overwrite all files, please be careful!
26
+
27
27
  ## Usage
28
28
 
29
29
  This gem is fully depends on `vue-cli`. You can do everything with [`vue.config.js`](https://cli.vuejs.org/config/) just don't break `manifest` plugin which required by `vue_cli-rails`.
@@ -36,4 +36,4 @@ You can put `app/assets/vue/manifest.dev.json` into your VCS ignore list.
36
36
 
37
37
  ## Warning
38
38
 
39
- Currently `vue.config.js` is reading configurations via `bundle exec rake vue:json_config`. You may suffer performance issue if your rake tasks are slow.
39
+ Currently `vue.config.js` is reading configurations from `vue.rails.js` which depends on `js-yaml`. It will fallback to `bundle exec rake vue:json_config` without `js-yaml` installed. You may suffer performance issue if your rake tasks are slow.
@@ -12,6 +12,6 @@ export default {
12
12
 
13
13
  <style>
14
14
  #foo {
15
- color: red
15
+ color: red;
16
16
  }
17
17
  </style>
@@ -1,20 +1,11 @@
1
1
  // Please do NOT edit settings required by vue_cli-rails
2
2
  /* [DO NOT EDIT!] begin */
3
- const { execSync } = require('child_process');
4
- const { env } = require('process');
5
3
  const WebpackAssetsManifest = require('webpack-assets-manifest');
6
4
  /* [DO NOT EDIT!] end */
7
5
 
8
6
  // const CompressionWebpackPlugin = require('compression-webpack-plugin');
9
7
  // const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
10
8
 
11
- const settings = JSON.parse(execSync('bundle exec rake vue:json_config', {
12
- cwd: __dirname,
13
- encoding: 'utf8',
14
- }));
15
- env.NODE_ENV = settings.env;
16
- const isProd = env.NODE_ENV === 'production';
17
-
18
9
  const {
19
10
  entry,
20
11
  css,
@@ -23,7 +14,8 @@ const {
23
14
  devServer,
24
15
  publicPath,
25
16
  manifestOutput,
26
- } = settings;
17
+ isProd,
18
+ } = require('./vue.rails');
27
19
 
28
20
  module.exports = {
29
21
  outputDir,
@@ -0,0 +1,63 @@
1
+ const { env } = require('process');
2
+
3
+ module.exports = (() => {
4
+ let settings = {};
5
+
6
+ /* eslint-disable global-require,import/no-extraneous-dependencies */
7
+ try {
8
+ const yaml = require('js-yaml');
9
+ const { readFileSync, readdirSync, lstatSync } = require('fs');
10
+ const { resolve } = require('path');
11
+
12
+ const railsEnv = env.RAILS_ENV || 'development';
13
+ const config = yaml.safeLoad(readFileSync(resolve('config/vue.yml'), 'utf8'))[railsEnv];
14
+ const root = resolve(__dirname);
15
+ const po = (config.public_output_path || 'vue_assets').replace(/(^\/+|\/+$)/g, '');
16
+ const { manifestOutput, alias = {}, devServer = {} } = config;
17
+ if (devServer.contentBase) {
18
+ devServer.contentBase = resolve(root, devServer.contentBase);
19
+ }
20
+ const entry = {};
21
+ const assetRoot = resolve(root, 'app/assets/vue/views');
22
+ const findAllJsFiles = (path) => {
23
+ readdirSync(path).forEach((fn) => {
24
+ const filename = resolve(path, fn);
25
+ const stat = lstatSync(filename);
26
+ if (stat.isDirectory()) {
27
+ findAllJsFiles(filename);
28
+ } else if (stat.isFile() && fn.endsWith('.js')) {
29
+ entry[filename.slice(assetRoot.length + 1, -3)] = filename;
30
+ }
31
+ });
32
+ };
33
+ findAllJsFiles(assetRoot);
34
+
35
+ settings = {
36
+ ...config,
37
+ env: railsEnv,
38
+ root,
39
+ outputDir: resolve(root, 'public', po),
40
+ publicPath: `/${po}/`,
41
+ alias: Object.keys(alias).reduce((obj, key) => ({
42
+ ...obj,
43
+ [key]: resolve(root, alias[key]),
44
+ }), {}),
45
+ manifestOutput: resolve(root, manifestOutput),
46
+ devServer,
47
+ entry,
48
+ };
49
+ } catch (e) {
50
+ const { execSync } = require('child_process');
51
+
52
+ settings = JSON.parse(execSync('bundle exec rake vue:json_config', {
53
+ cwd: __dirname,
54
+ encoding: 'utf8',
55
+ }));
56
+ }
57
+ /* eslint-enable global-require,import/no-extraneous-dependencies */
58
+
59
+ return {
60
+ ...settings,
61
+ isProd: settings.env === 'production',
62
+ };
63
+ })();
data/lib/tasks/vue.rake CHANGED
@@ -9,7 +9,7 @@ namespace :vue do
9
9
  FileUtils.chdir root
10
10
  # `vue create .` and dependencies
11
11
  pm.exec('vue create', "-n -m #{pm.package_manager} .")
12
- pm.add '-D webpack-assets-manifest cross-env'
12
+ pm.add '-D webpack-assets-manifest js-yaml'
13
13
  FileUtils.rm_rf root.join('src')
14
14
 
15
15
  # dirs under `app`
@@ -1,5 +1,5 @@
1
1
  module VueCli
2
2
  module Rails
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -20,9 +20,9 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.required_ruby_version = ">= 2.2"
22
22
 
23
- spec.add_dependency "activesupport", "~> 4.2"
24
- spec.add_dependency "railties", "~> 4.2"
25
- spec.add_dependency "rack-proxy", "~> 0.6"
23
+ spec.add_dependency "activesupport", ">= 4.2"
24
+ spec.add_dependency "railties", ">= 4.2"
25
+ spec.add_dependency "rack-proxy", ">= 0.6"
26
26
 
27
27
  spec.add_development_dependency "bundler", "~> 1.12"
28
28
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vue_cli-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Chen
@@ -14,42 +14,42 @@ dependencies:
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: railties
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '4.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '4.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rack-proxy
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.6'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.6'
55
55
  - !ruby/object:Gem::Dependency
@@ -122,6 +122,7 @@ files:
122
122
  - lib/source/app/views/vue/bar.html.erb
123
123
  - lib/source/app/views/vue/foo.html.erb
124
124
  - lib/source/vue.config.js
125
+ - lib/source/vue.rails.js
125
126
  - lib/source/vue.yml
126
127
  - lib/tasks/vue.rake
127
128
  - lib/views/layouts/vue.erb