webpacker 5.2.1 → 6.0.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc.js +1 -1
- data/.gitignore +2 -0
- data/.node-version +1 -1
- data/.rubocop.yml +11 -16
- data/6_0_upgrade.md +43 -0
- data/CHANGELOG.md +25 -0
- data/CONTRIBUTING.md +1 -1
- data/Gemfile.lock +17 -11
- data/README.md +220 -99
- data/lib/install/config/webpack/base.js +3 -0
- data/lib/install/config/webpack/development.js +2 -2
- data/lib/install/config/webpack/production.js +2 -2
- data/lib/install/config/webpack/test.js +2 -2
- data/lib/install/config/webpacker.yml +8 -37
- data/lib/install/javascript/packs/application.css +9 -0
- data/lib/install/javascript/packs/application.js +3 -1
- data/lib/install/template.rb +33 -19
- data/lib/tasks/webpacker.rake +2 -11
- data/lib/tasks/webpacker/binstubs.rake +6 -4
- data/lib/tasks/webpacker/check_binstubs.rake +4 -4
- data/lib/tasks/webpacker/check_yarn.rake +1 -2
- data/lib/tasks/webpacker/compile.rake +4 -2
- data/lib/tasks/webpacker/info.rake +12 -10
- data/lib/tasks/webpacker/install.rake +6 -4
- data/lib/tasks/webpacker/verify_install.rake +2 -1
- data/lib/tasks/webpacker/yarn_install.rake +9 -1
- data/lib/webpacker/commands.rb +1 -1
- data/lib/webpacker/compiler.rb +15 -8
- data/lib/webpacker/configuration.rb +6 -30
- data/lib/webpacker/dev_server_runner.rb +21 -2
- data/lib/webpacker/helper.rb +22 -32
- data/lib/webpacker/manifest.rb +1 -1
- data/lib/webpacker/version.rb +1 -1
- data/lib/webpacker/webpack_runner.rb +5 -0
- data/package.json +23 -39
- data/package/__tests__/config.js +5 -37
- data/package/__tests__/development.js +9 -11
- data/package/__tests__/env.js +12 -4
- data/package/__tests__/production.js +6 -6
- data/package/__tests__/staging.js +7 -6
- data/package/__tests__/test.js +4 -5
- data/package/babel/preset.js +55 -0
- data/package/config.js +3 -11
- data/package/env.js +8 -2
- data/package/environments/__tests__/base.js +15 -47
- data/package/environments/base.js +62 -125
- data/package/environments/development.js +45 -44
- data/package/environments/production.js +63 -68
- data/package/environments/test.js +2 -2
- data/package/index.js +13 -8
- data/package/rules/babel.js +9 -7
- data/package/rules/coffee.js +6 -0
- data/package/rules/erb.js +15 -0
- data/package/rules/file.js +19 -19
- data/package/rules/index.js +15 -18
- data/package/rules/less.js +22 -0
- data/package/rules/sass.js +12 -9
- data/package/rules/svg.js +20 -0
- data/package/utils/get_style_rule.js +26 -36
- data/package/utils/helpers.js +26 -35
- data/test/compiler_test.rb +0 -12
- data/test/configuration_test.rb +1 -32
- data/test/dev_server_runner_test.rb +24 -5
- data/test/engine_rake_tasks_test.rb +39 -0
- data/test/helper_test.rb +15 -9
- data/test/mounted_app/Rakefile +4 -0
- data/test/mounted_app/test/dummy/Rakefile +3 -0
- data/test/mounted_app/test/dummy/bin/rails +3 -0
- data/test/mounted_app/test/dummy/bin/rake +3 -0
- data/test/mounted_app/test/dummy/config.ru +5 -0
- data/test/mounted_app/test/dummy/config/application.rb +10 -0
- data/test/mounted_app/test/dummy/config/environment.rb +3 -0
- data/test/mounted_app/test/dummy/config/webpacker.yml +75 -0
- data/test/mounted_app/test/dummy/package.json +7 -0
- data/test/rake_tasks_test.rb +1 -10
- data/test/test_app/config/webpacker.yml +1 -25
- data/test/test_app/config/webpacker_public_root.yml +0 -1
- data/test/test_app/public/packs/manifest.json +17 -13
- data/test/test_app/some.config.js +0 -0
- data/test/webpack_runner_test.rb +9 -3
- data/webpacker.gemspec +1 -1
- data/yarn.lock +1858 -4915
- metadata +44 -90
- data/.travis.yml +0 -43
- data/docs/assets.md +0 -119
- data/docs/cloud9.md +0 -310
- data/docs/css.md +0 -308
- data/docs/deployment.md +0 -130
- data/docs/docker.md +0 -68
- data/docs/engines.md +0 -213
- data/docs/env.md +0 -63
- data/docs/es6.md +0 -72
- data/docs/folder-structure.md +0 -66
- data/docs/integrations.md +0 -220
- data/docs/misc.md +0 -23
- data/docs/props.md +0 -223
- data/docs/target.md +0 -22
- data/docs/testing.md +0 -136
- data/docs/troubleshooting.md +0 -158
- data/docs/typescript.md +0 -190
- data/docs/v4-upgrade.md +0 -142
- data/docs/webpack-dev-server.md +0 -92
- data/docs/webpack.md +0 -364
- data/docs/yarn.md +0 -23
- data/lib/install/angular.rb +0 -23
- data/lib/install/coffee.rb +0 -25
- data/lib/install/config/.browserslistrc +0 -1
- data/lib/install/config/babel.config.js +0 -70
- data/lib/install/config/postcss.config.js +0 -12
- data/lib/install/config/webpack/environment.js +0 -3
- data/lib/install/elm.rb +0 -39
- data/lib/install/erb.rb +0 -25
- data/lib/install/examples/angular/hello_angular.js +0 -7
- data/lib/install/examples/angular/hello_angular/app/app.component.ts +0 -9
- data/lib/install/examples/angular/hello_angular/app/app.module.ts +0 -16
- data/lib/install/examples/angular/hello_angular/index.ts +0 -8
- data/lib/install/examples/angular/hello_angular/polyfills.ts +0 -73
- data/lib/install/examples/coffee/hello_coffee.coffee +0 -4
- data/lib/install/examples/elm/Main.elm +0 -55
- data/lib/install/examples/elm/hello_elm.js +0 -16
- data/lib/install/examples/erb/hello_erb.js.erb +0 -6
- data/lib/install/examples/react/babel.config.js +0 -87
- data/lib/install/examples/react/hello_react.jsx +0 -26
- data/lib/install/examples/react/tsconfig.json +0 -21
- data/lib/install/examples/stimulus/application.js +0 -1
- data/lib/install/examples/stimulus/controllers/hello_controller.js +0 -18
- data/lib/install/examples/stimulus/controllers/index.js +0 -9
- data/lib/install/examples/svelte/app.svelte +0 -11
- data/lib/install/examples/svelte/hello_svelte.js +0 -20
- data/lib/install/examples/typescript/hello_typescript.ts +0 -4
- data/lib/install/examples/typescript/tsconfig.json +0 -24
- data/lib/install/examples/vue/app.vue +0 -22
- data/lib/install/examples/vue/hello_vue.js +0 -72
- data/lib/install/loaders/coffee.js +0 -6
- data/lib/install/loaders/elm.js +0 -25
- data/lib/install/loaders/erb.js +0 -11
- data/lib/install/loaders/svelte.js +0 -9
- data/lib/install/loaders/vue.js +0 -6
- data/lib/install/react.rb +0 -18
- data/lib/install/stimulus.rb +0 -12
- data/lib/install/svelte.rb +0 -29
- data/lib/install/typescript.rb +0 -39
- data/lib/install/vue.rb +0 -49
- data/lib/tasks/installers.rake +0 -42
- data/package/config_types/__tests__/config_list.js +0 -118
- data/package/config_types/__tests__/config_object.js +0 -43
- data/package/config_types/config_list.js +0 -75
- data/package/config_types/config_object.js +0 -55
- data/package/config_types/index.js +0 -7
- data/package/rules/module.css.js +0 -3
- data/package/rules/module.sass.js +0 -8
- data/package/rules/node_modules.js +0 -22
- data/package/utils/__tests__/deep_assign.js +0 -32
- data/package/utils/__tests__/deep_merge.js +0 -10
- data/package/utils/__tests__/get_style_rule.js +0 -65
- data/package/utils/__tests__/objectify.js +0 -9
- data/package/utils/deep_assign.js +0 -22
- data/package/utils/deep_merge.js +0 -22
- data/package/utils/objectify.js +0 -3
@@ -1,26 +0,0 @@
|
|
1
|
-
// Run this example by adding <%= javascript_pack_tag 'hello_react' %> to the head of your layout file,
|
2
|
-
// like app/views/layouts/application.html.erb. All it does is render <div>Hello React</div> at the bottom
|
3
|
-
// of the page.
|
4
|
-
|
5
|
-
import React from 'react'
|
6
|
-
import ReactDOM from 'react-dom'
|
7
|
-
import PropTypes from 'prop-types'
|
8
|
-
|
9
|
-
const Hello = props => (
|
10
|
-
<div>Hello {props.name}!</div>
|
11
|
-
)
|
12
|
-
|
13
|
-
Hello.defaultProps = {
|
14
|
-
name: 'David'
|
15
|
-
}
|
16
|
-
|
17
|
-
Hello.propTypes = {
|
18
|
-
name: PropTypes.string
|
19
|
-
}
|
20
|
-
|
21
|
-
document.addEventListener('DOMContentLoaded', () => {
|
22
|
-
ReactDOM.render(
|
23
|
-
<Hello name="React" />,
|
24
|
-
document.body.appendChild(document.createElement('div')),
|
25
|
-
)
|
26
|
-
})
|
@@ -1,21 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"compilerOptions": {
|
3
|
-
"declaration": false,
|
4
|
-
"emitDecoratorMetadata": true,
|
5
|
-
"experimentalDecorators": true,
|
6
|
-
"lib": ["es6", "dom"],
|
7
|
-
"module": "es6",
|
8
|
-
"moduleResolution": "node",
|
9
|
-
"sourceMap": true,
|
10
|
-
"target": "es5",
|
11
|
-
"jsx": "react",
|
12
|
-
"noEmit": true
|
13
|
-
},
|
14
|
-
"exclude": [
|
15
|
-
"**/*.spec.ts",
|
16
|
-
"node_modules",
|
17
|
-
"vendor",
|
18
|
-
"public"
|
19
|
-
],
|
20
|
-
"compileOnSave": false
|
21
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
import "controllers"
|
@@ -1,18 +0,0 @@
|
|
1
|
-
// Visit The Stimulus Handbook for more details
|
2
|
-
// https://stimulusjs.org/handbook/introduction
|
3
|
-
//
|
4
|
-
// This example controller works with specially annotated HTML like:
|
5
|
-
//
|
6
|
-
// <div data-controller="hello">
|
7
|
-
// <h1 data-target="hello.output"></h1>
|
8
|
-
// </div>
|
9
|
-
|
10
|
-
import { Controller } from "stimulus"
|
11
|
-
|
12
|
-
export default class extends Controller {
|
13
|
-
static targets = [ "output" ]
|
14
|
-
|
15
|
-
connect() {
|
16
|
-
this.outputTarget.textContent = 'Hello, Stimulus!'
|
17
|
-
}
|
18
|
-
}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
// Load all the controllers within this directory and all subdirectories.
|
2
|
-
// Controller files must be named *_controller.js.
|
3
|
-
|
4
|
-
import { Application } from "stimulus"
|
5
|
-
import { definitionsFromContext } from "stimulus/webpack-helpers"
|
6
|
-
|
7
|
-
const application = Application.start()
|
8
|
-
const context = require.context("controllers", true, /_controller\.js$/)
|
9
|
-
application.load(definitionsFromContext(context))
|
@@ -1,20 +0,0 @@
|
|
1
|
-
/* eslint no-console: 0 */
|
2
|
-
// Run this example by adding <%= javascript_pack_tag 'hello_svelte' %> (and
|
3
|
-
// <%= stylesheet_pack_tag 'hello_svelte' %> if you have styles in your component)
|
4
|
-
// to the head of your layout file,
|
5
|
-
// like app/views/layouts/application.html.erb.
|
6
|
-
// All it does is render <div>Hello Svelte!</div> at the bottom of the page.
|
7
|
-
|
8
|
-
import App from '../app.svelte'
|
9
|
-
|
10
|
-
document.addEventListener('DOMContentLoaded', () => {
|
11
|
-
const app = new App({
|
12
|
-
target: document.body,
|
13
|
-
props: {
|
14
|
-
name: 'Svelte'
|
15
|
-
}
|
16
|
-
});
|
17
|
-
|
18
|
-
window.app = app;
|
19
|
-
})
|
20
|
-
|
@@ -1,24 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"compilerOptions": {
|
3
|
-
"declaration": false,
|
4
|
-
"emitDecoratorMetadata": true,
|
5
|
-
"experimentalDecorators": true,
|
6
|
-
"lib": ["es6", "dom"],
|
7
|
-
"module": "es6",
|
8
|
-
"moduleResolution": "node",
|
9
|
-
"baseUrl": ".",
|
10
|
-
"paths": {
|
11
|
-
"*": ["node_modules/*", "app/javascript/*"]
|
12
|
-
},
|
13
|
-
"sourceMap": true,
|
14
|
-
"target": "es5",
|
15
|
-
"noEmit": true
|
16
|
-
},
|
17
|
-
"exclude": [
|
18
|
-
"**/*.spec.ts",
|
19
|
-
"node_modules",
|
20
|
-
"vendor",
|
21
|
-
"public"
|
22
|
-
],
|
23
|
-
"compileOnSave": false
|
24
|
-
}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
<template>
|
2
|
-
<div id="app">
|
3
|
-
<p>{{ message }}</p>
|
4
|
-
</div>
|
5
|
-
</template>
|
6
|
-
|
7
|
-
<script>
|
8
|
-
export default {
|
9
|
-
data: function () {
|
10
|
-
return {
|
11
|
-
message: "Hello Vue!"
|
12
|
-
}
|
13
|
-
}
|
14
|
-
}
|
15
|
-
</script>
|
16
|
-
|
17
|
-
<style scoped>
|
18
|
-
p {
|
19
|
-
font-size: 2em;
|
20
|
-
text-align: center;
|
21
|
-
}
|
22
|
-
</style>
|
@@ -1,72 +0,0 @@
|
|
1
|
-
/* eslint no-console: 0 */
|
2
|
-
// Run this example by adding <%= javascript_pack_tag 'hello_vue' %> (and
|
3
|
-
// <%= stylesheet_pack_tag 'hello_vue' %> if you have styles in your component)
|
4
|
-
// to the head of your layout file,
|
5
|
-
// like app/views/layouts/application.html.erb.
|
6
|
-
// All it does is render <div>Hello Vue</div> at the bottom of the page.
|
7
|
-
|
8
|
-
import Vue from 'vue'
|
9
|
-
import App from '../app.vue'
|
10
|
-
|
11
|
-
document.addEventListener('DOMContentLoaded', () => {
|
12
|
-
const app = new Vue({
|
13
|
-
render: h => h(App)
|
14
|
-
}).$mount()
|
15
|
-
document.body.appendChild(app.$el)
|
16
|
-
|
17
|
-
console.log(app)
|
18
|
-
})
|
19
|
-
|
20
|
-
|
21
|
-
// The above code uses Vue without the compiler, which means you cannot
|
22
|
-
// use Vue to target elements in your existing html templates. You would
|
23
|
-
// need to always use single file components.
|
24
|
-
// To be able to target elements in your existing html/erb templates,
|
25
|
-
// comment out the above code and uncomment the below
|
26
|
-
// Add <%= javascript_pack_tag 'hello_vue' %> to your layout
|
27
|
-
// Then add this markup to your html template:
|
28
|
-
//
|
29
|
-
// <div id='hello'>
|
30
|
-
// {{message}}
|
31
|
-
// <app></app>
|
32
|
-
// </div>
|
33
|
-
|
34
|
-
|
35
|
-
// import Vue from 'vue/dist/vue.esm'
|
36
|
-
// import App from '../app.vue'
|
37
|
-
//
|
38
|
-
// document.addEventListener('DOMContentLoaded', () => {
|
39
|
-
// const app = new Vue({
|
40
|
-
// el: '#hello',
|
41
|
-
// data: {
|
42
|
-
// message: "Can you say hello?"
|
43
|
-
// },
|
44
|
-
// components: { App }
|
45
|
-
// })
|
46
|
-
// })
|
47
|
-
//
|
48
|
-
//
|
49
|
-
//
|
50
|
-
// If the project is using turbolinks, install 'vue-turbolinks':
|
51
|
-
//
|
52
|
-
// yarn add vue-turbolinks
|
53
|
-
//
|
54
|
-
// Then uncomment the code block below:
|
55
|
-
//
|
56
|
-
// import TurbolinksAdapter from 'vue-turbolinks'
|
57
|
-
// import Vue from 'vue/dist/vue.esm'
|
58
|
-
// import App from '../app.vue'
|
59
|
-
//
|
60
|
-
// Vue.use(TurbolinksAdapter)
|
61
|
-
//
|
62
|
-
// document.addEventListener('turbolinks:load', () => {
|
63
|
-
// const app = new Vue({
|
64
|
-
// el: '#hello',
|
65
|
-
// data: () => {
|
66
|
-
// return {
|
67
|
-
// message: "Can you say hello?"
|
68
|
-
// }
|
69
|
-
// },
|
70
|
-
// components: { App }
|
71
|
-
// })
|
72
|
-
// })
|
data/lib/install/loaders/elm.js
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
const { resolve } = require('path')
|
2
|
-
|
3
|
-
const isProduction = process.env.NODE_ENV === 'production'
|
4
|
-
const isDevelopment = process.env.NODE_ENV === 'development'
|
5
|
-
const elmSource = resolve(process.cwd())
|
6
|
-
const elmBinary = `${elmSource}/node_modules/.bin/elm`
|
7
|
-
|
8
|
-
const options = {
|
9
|
-
cwd: elmSource,
|
10
|
-
pathToElm: elmBinary,
|
11
|
-
optimize: isProduction,
|
12
|
-
verbose: isDevelopment,
|
13
|
-
debug: isDevelopment
|
14
|
-
}
|
15
|
-
|
16
|
-
const elmWebpackLoader = {
|
17
|
-
loader: 'elm-webpack-loader',
|
18
|
-
options: options
|
19
|
-
}
|
20
|
-
|
21
|
-
module.exports = {
|
22
|
-
test: /\.elm(\.erb)?$/,
|
23
|
-
exclude: [/elm-stuff/, /node_modules/],
|
24
|
-
use: isProduction ? [elmWebpackLoader] : [{ loader: 'elm-hot-webpack-loader' }, elmWebpackLoader]
|
25
|
-
}
|
data/lib/install/loaders/erb.js
DELETED
data/lib/install/loaders/vue.js
DELETED
data/lib/install/react.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require "webpacker/configuration"
|
2
|
-
require "fileutils"
|
3
|
-
|
4
|
-
replace_babel_config = FileUtils.compare_file(Rails.root.join("babel.config.js"), "#{__dir__}/config/babel.config.js")
|
5
|
-
|
6
|
-
say "Copying babel.config.js to app root directory"
|
7
|
-
copy_file "#{__dir__}/examples/react/babel.config.js", "babel.config.js", force: replace_babel_config
|
8
|
-
|
9
|
-
say "Copying react example entry file to #{Webpacker.config.source_entry_path}"
|
10
|
-
copy_file "#{__dir__}/examples/react/hello_react.jsx", "#{Webpacker.config.source_entry_path}/hello_react.jsx"
|
11
|
-
|
12
|
-
say "Updating webpack paths to include .jsx file extension"
|
13
|
-
insert_into_file Webpacker.config.config_path, "- .jsx\n".indent(4), after: /\s+extensions:\n/
|
14
|
-
|
15
|
-
say "Installing all react dependencies"
|
16
|
-
run "yarn add react react-dom @babel/preset-react prop-types babel-plugin-transform-react-remove-prop-types"
|
17
|
-
|
18
|
-
say "Webpacker now supports react.js 🎉", :green
|
data/lib/install/stimulus.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
say "Appending Stimulus setup code to #{Webpacker.config.source_entry_path}/application.js"
|
2
|
-
append_to_file "#{Webpacker.config.source_entry_path}/application.js" do
|
3
|
-
"\n" + open("#{__dir__}/examples/stimulus/application.js").read
|
4
|
-
end
|
5
|
-
|
6
|
-
say "Creating controllers directory"
|
7
|
-
directory "#{__dir__}/examples/stimulus/controllers", "#{Webpacker.config.source_path}/controllers"
|
8
|
-
|
9
|
-
say "Installing all Stimulus dependencies"
|
10
|
-
run "yarn add stimulus"
|
11
|
-
|
12
|
-
say "Webpacker now supports Stimulus.js 🎉", :green
|
data/lib/install/svelte.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require "webpacker/configuration"
|
2
|
-
|
3
|
-
say "Copying svelte loader to config/webpack/loaders"
|
4
|
-
copy_file "#{__dir__}/loaders/svelte.js", Rails.root.join("config/webpack/loaders/svelte.js").to_s
|
5
|
-
|
6
|
-
say "Adding svelte loader to config/webpack/environment.js"
|
7
|
-
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
8
|
-
"const svelte = require('./loaders/svelte')\n",
|
9
|
-
after: /require\(('|")@rails\/webpacker\1\);?\n/
|
10
|
-
|
11
|
-
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
12
|
-
"environment.loaders.prepend('svelte', svelte)\n",
|
13
|
-
before: "module.exports"
|
14
|
-
|
15
|
-
say "Copying Svelte example entry file to #{Webpacker.config.source_entry_path}"
|
16
|
-
copy_file "#{__dir__}/examples/svelte/hello_svelte.js",
|
17
|
-
"#{Webpacker.config.source_entry_path}/hello_svelte.js"
|
18
|
-
|
19
|
-
say "Copying Svelte app file to #{Webpacker.config.source_path}"
|
20
|
-
copy_file "#{__dir__}/examples/svelte/app.svelte",
|
21
|
-
"#{Webpacker.config.source_path}/app.svelte"
|
22
|
-
|
23
|
-
say "Installing all Svelte dependencies"
|
24
|
-
run "yarn add svelte svelte-loader"
|
25
|
-
|
26
|
-
say "Updating webpack paths to include .svelte file extension"
|
27
|
-
insert_into_file Webpacker.config.config_path, "- .svelte\n".indent(4), after: /\s+extensions:\n/
|
28
|
-
|
29
|
-
say "Webpacker now supports Svelte 🎉", :green
|
data/lib/install/typescript.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require "webpacker/configuration"
|
2
|
-
|
3
|
-
additional_packages = ""
|
4
|
-
example_source = "typescript"
|
5
|
-
|
6
|
-
# Additional configuration is required for React projects
|
7
|
-
package_json = Rails.root.join("package.json")
|
8
|
-
if File.exist?(package_json)
|
9
|
-
package = JSON.parse(File.read(package_json))
|
10
|
-
package["dependencies"] ||= {}
|
11
|
-
|
12
|
-
if package["dependencies"].keys.include?("react")
|
13
|
-
additional_packages = "@types/react @types/react-dom"
|
14
|
-
example_source = "react"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
say "Adding TypeScript preset to babel.config.js"
|
19
|
-
insert_into_file Rails.root.join("babel.config.js").to_s,
|
20
|
-
",\n ['@babel/preset-typescript', { 'allExtensions': true, 'isTSX': true }]",
|
21
|
-
before: /\s*\].filter\(Boolean\),\n\s*plugins: \[/
|
22
|
-
|
23
|
-
say "Copying tsconfig.json to the Rails root directory for typescript"
|
24
|
-
copy_file "#{__dir__}/examples/#{example_source}/tsconfig.json", "tsconfig.json"
|
25
|
-
|
26
|
-
say "Updating webpack paths to include .ts file extension"
|
27
|
-
insert_into_file Webpacker.config.config_path, "- .ts\n".indent(4), after: /\s+extensions:\n/
|
28
|
-
|
29
|
-
say "Updating webpack paths to include .tsx file extension"
|
30
|
-
insert_into_file Webpacker.config.config_path, "- .tsx\n".indent(4), after: /\s+extensions:\n/
|
31
|
-
|
32
|
-
say "Copying the example entry file to #{Webpacker.config.source_entry_path}"
|
33
|
-
copy_file "#{__dir__}/examples/typescript/hello_typescript.ts",
|
34
|
-
"#{Webpacker.config.source_entry_path}/hello_typescript.ts"
|
35
|
-
|
36
|
-
say "Installing all typescript dependencies"
|
37
|
-
run "yarn add typescript @babel/preset-typescript #{additional_packages}"
|
38
|
-
|
39
|
-
say "Webpacker now supports typescript 🎉", :green
|
data/lib/install/vue.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require "webpacker/configuration"
|
2
|
-
|
3
|
-
say "Copying vue loader to config/webpack/loaders"
|
4
|
-
copy_file "#{__dir__}/loaders/vue.js", Rails.root.join("config/webpack/loaders/vue.js").to_s
|
5
|
-
|
6
|
-
say "Adding vue loader plugin to config/webpack/environment.js"
|
7
|
-
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
8
|
-
"const { VueLoaderPlugin } = require('vue-loader')\n",
|
9
|
-
after: /require\(('|")@rails\/webpacker\1\);?\n/
|
10
|
-
|
11
|
-
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
12
|
-
"environment.plugins.prepend('VueLoaderPlugin', new VueLoaderPlugin())\n",
|
13
|
-
before: "module.exports"
|
14
|
-
|
15
|
-
say "Adding vue loader to config/webpack/environment.js"
|
16
|
-
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
17
|
-
"const vue = require('./loaders/vue')\n",
|
18
|
-
after: "require('vue-loader')\n"
|
19
|
-
|
20
|
-
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
21
|
-
"environment.loaders.prepend('vue', vue)\n",
|
22
|
-
before: "module.exports"
|
23
|
-
|
24
|
-
say "Updating webpack paths to include .vue file extension"
|
25
|
-
insert_into_file Webpacker.config.config_path, "- .vue\n".indent(4), after: /\s+extensions:\n/
|
26
|
-
|
27
|
-
say "Copying the example entry file to #{Webpacker.config.source_entry_path}"
|
28
|
-
copy_file "#{__dir__}/examples/vue/hello_vue.js",
|
29
|
-
"#{Webpacker.config.source_entry_path}/hello_vue.js"
|
30
|
-
|
31
|
-
say "Copying Vue app file to #{Webpacker.config.source_entry_path}"
|
32
|
-
copy_file "#{__dir__}/examples/vue/app.vue",
|
33
|
-
"#{Webpacker.config.source_path}/app.vue"
|
34
|
-
|
35
|
-
say "Installing all Vue dependencies"
|
36
|
-
run "yarn add vue vue-loader vue-template-compiler"
|
37
|
-
|
38
|
-
if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR > 1
|
39
|
-
say "You need to enable unsafe-eval rule.", :yellow
|
40
|
-
say "This can be done in Rails 5.2+ for development environment in the CSP initializer", :yellow
|
41
|
-
say "config/initializers/content_security_policy.rb with a snippet like this:", :yellow
|
42
|
-
say "if Rails.env.development?", :yellow
|
43
|
-
say " policy.script_src :self, :https, :unsafe_eval", :yellow
|
44
|
-
say "else", :yellow
|
45
|
-
say " policy.script_src :self, :https", :yellow
|
46
|
-
say "end", :yellow
|
47
|
-
end
|
48
|
-
|
49
|
-
say "Webpacker now supports Vue.js 🎉", :green
|