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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -3
- data/lib/source/app/assets/vue/components/views/Foo.vue +1 -1
- data/lib/source/vue.config.js +2 -10
- data/lib/source/vue.rails.js +63 -0
- data/lib/tasks/vue.rake +1 -1
- data/lib/vue_cli/rails/version.rb +1 -1
- data/vue_cli-rails.gemspec +3 -3
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c73bc49c1a774fc57b0c9d106af051b7f2a8bda5
|
4
|
+
data.tar.gz: 3bd24fe745d33907c86aa1928bb086656eba2a14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 308ad9d983e729cf74e8ba2f8ae71152f132d1b842f18cb0d3fc1b4d3d3c8ae5d10b5e70e855c31e6a610d5d042dd35efb91e037942ffdd878e77eb11175a76a
|
7
|
+
data.tar.gz: 68f2f03b3a3fe0f33f94c2809f25dcbb96681d03b8fe01ab30182cf04b388308a4aea536536acf146acfbc29873534aec850402564fdb347b27519f6e6a3abda
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
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
|
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.
|
data/lib/source/vue.config.js
CHANGED
@@ -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
|
-
|
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
|
12
|
+
pm.add '-D webpack-assets-manifest js-yaml'
|
13
13
|
FileUtils.rm_rf root.join('src')
|
14
14
|
|
15
15
|
# dirs under `app`
|
data/vue_cli-rails.gemspec
CHANGED
@@ -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", "
|
24
|
-
spec.add_dependency "railties", "
|
25
|
-
spec.add_dependency "rack-proxy", "
|
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.
|
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
|