rails_external_assets 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/examples/webpack/.babelrc +3 -0
- data/examples/webpack/.env +1 -0
- data/examples/webpack/.gitignore +22 -0
- data/examples/webpack/Gemfile +49 -0
- data/examples/webpack/Gemfile.lock +166 -0
- data/examples/webpack/README.md +8 -0
- data/examples/webpack/Rakefile +6 -0
- data/examples/webpack/app/assets/images/.keep +0 -0
- data/examples/webpack/app/assets/javascripts/application.js +13 -0
- data/examples/webpack/app/assets/stylesheets/application.css +15 -0
- data/examples/webpack/app/assets/webpack/ColorConverter/index.js +40 -0
- data/examples/webpack/app/assets/webpack/ColorConverter/index.scss +32 -0
- data/examples/webpack/app/assets/webpack/ColorConverter/initializer.js +7 -0
- data/examples/webpack/app/assets/webpack/logger.js +16 -0
- data/examples/webpack/app/controllers/application_controller.rb +8 -0
- data/examples/webpack/app/controllers/concerns/.keep +0 -0
- data/examples/webpack/app/helpers/application_helper.rb +2 -0
- data/examples/webpack/app/mailers/.keep +0 -0
- data/examples/webpack/app/models/.keep +0 -0
- data/examples/webpack/app/models/concerns/.keep +0 -0
- data/examples/webpack/app/views/application/index.html.erb +13 -0
- data/examples/webpack/app/views/layouts/application.html.erb +14 -0
- data/examples/webpack/bin/bundle +3 -0
- data/examples/webpack/bin/rails +9 -0
- data/examples/webpack/bin/rake +9 -0
- data/examples/webpack/bin/setup +29 -0
- data/examples/webpack/bin/spring +15 -0
- data/examples/webpack/config/application.rb +26 -0
- data/examples/webpack/config/boot.rb +3 -0
- data/examples/webpack/config/database.yml +25 -0
- data/examples/webpack/config/environment.rb +5 -0
- data/examples/webpack/config/environments/development.rb +41 -0
- data/examples/webpack/config/environments/production.rb +79 -0
- data/examples/webpack/config/environments/test.rb +42 -0
- data/examples/webpack/config/initializers/assets.rb +11 -0
- data/examples/webpack/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/webpack/config/initializers/cookies_serializer.rb +3 -0
- data/examples/webpack/config/initializers/filter_parameter_logging.rb +4 -0
- data/examples/webpack/config/initializers/inflections.rb +16 -0
- data/examples/webpack/config/initializers/mime_types.rb +4 -0
- data/examples/webpack/config/initializers/rails_external_assets.rb +10 -0
- data/examples/webpack/config/initializers/session_store.rb +3 -0
- data/examples/webpack/config/initializers/wrap_parameters.rb +14 -0
- data/examples/webpack/config/locales/en.yml +23 -0
- data/examples/webpack/config/routes.rb +3 -0
- data/examples/webpack/config/secrets.yml +22 -0
- data/examples/webpack/config.ru +4 -0
- data/examples/webpack/db/seeds.rb +7 -0
- data/examples/webpack/lib/assets/.keep +0 -0
- data/examples/webpack/lib/tasks/.keep +0 -0
- data/examples/webpack/log/.keep +0 -0
- data/examples/webpack/package.json +41 -0
- data/examples/webpack/public/404.html +67 -0
- data/examples/webpack/public/422.html +67 -0
- data/examples/webpack/public/500.html +66 -0
- data/examples/webpack/public/favicon.ico +0 -0
- data/examples/webpack/public/robots.txt +5 -0
- data/examples/webpack/test/controllers/.keep +0 -0
- data/examples/webpack/test/fixtures/.keep +0 -0
- data/examples/webpack/test/helpers/.keep +0 -0
- data/examples/webpack/test/integration/.keep +0 -0
- data/examples/webpack/test/mailers/.keep +0 -0
- data/examples/webpack/test/models/.keep +0 -0
- data/examples/webpack/test/test_helper.rb +10 -0
- data/examples/webpack/vendor/assets/javascripts/.keep +0 -0
- data/examples/webpack/vendor/assets/stylesheets/.keep +0 -0
- data/examples/webpack/webpack.config.js +112 -0
- data/lib/rails_external_assets/configuration.rb +1 -1
- data/lib/rails_external_assets/version.rb +1 -1
- metadata +70 -3
@@ -0,0 +1,112 @@
|
|
1
|
+
var webpack = require('webpack');
|
2
|
+
var path = require('path');
|
3
|
+
var glob = require('glob');
|
4
|
+
// webpack plugins
|
5
|
+
var ManifestPlugin = require('webpack-manifest-plugin');
|
6
|
+
var WriteFilePlugin = require('write-file-webpack-plugin');
|
7
|
+
// postcss plugins
|
8
|
+
var autoprefixer = require('autoprefixer');
|
9
|
+
|
10
|
+
require('dotenv').load({silent: true});
|
11
|
+
|
12
|
+
// environment variables
|
13
|
+
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
14
|
+
process.env.BABEL_ENV = process.env.NODE_ENV;
|
15
|
+
var isProduction = process.env.NODE_ENV === 'production';
|
16
|
+
var isDevelopment = process.env.NODE_ENV === 'development';
|
17
|
+
var isStaging = process.env.NODE_ENV === 'staging';
|
18
|
+
var WEBPACK_PORT = process.env.WEBPACK_PORT || 8000;
|
19
|
+
|
20
|
+
// webpack config variables
|
21
|
+
var outputPath = path.join(__dirname, '/public/webpack-assets');
|
22
|
+
|
23
|
+
function getPlugins() {
|
24
|
+
var plugins = [
|
25
|
+
new webpack.optimize.OccurenceOrderPlugin(),
|
26
|
+
new ManifestPlugin({filename: 'manifest.json'}),
|
27
|
+
new WriteFilePlugin({log: false}),
|
28
|
+
];
|
29
|
+
|
30
|
+
if (isProduction) {
|
31
|
+
plugins.push(new webpack.DefinePlugin({
|
32
|
+
'process.env': {
|
33
|
+
NODE_ENV: JSON.stringify('production')
|
34
|
+
}
|
35
|
+
}));
|
36
|
+
plugins.push(new webpack.optimize.OccurenceOrderPlugin());
|
37
|
+
plugins.push(new webpack.optimize.DedupePlugin());
|
38
|
+
plugins.push(new webpack.optimize.UglifyJsPlugin({
|
39
|
+
compress: {warnings: false}
|
40
|
+
}));
|
41
|
+
}
|
42
|
+
return plugins;
|
43
|
+
}
|
44
|
+
|
45
|
+
function getOutputFilename(extension) {
|
46
|
+
var outputFilename = '';
|
47
|
+
if (isProduction) {
|
48
|
+
outputFilename = '[name]-[chunkhash].min' + extension;
|
49
|
+
} else {
|
50
|
+
outputFilename = '[name]' + extension;
|
51
|
+
}
|
52
|
+
|
53
|
+
return outputFilename;
|
54
|
+
}
|
55
|
+
|
56
|
+
function getEntries(basePath) {
|
57
|
+
var entries = glob.sync(path.join(basePath, '**/*.*')).reduce(function(entryMap, entry) {
|
58
|
+
var trimmedEntry = entry.replace(basePath, '');
|
59
|
+
var trimmedEntryWithoutExt = trimmedEntry.replace(/\..+$/, '');
|
60
|
+
entryMap[trimmedEntryWithoutExt] = [trimmedEntry];
|
61
|
+
return entryMap;
|
62
|
+
}, {});
|
63
|
+
return entries;
|
64
|
+
}
|
65
|
+
|
66
|
+
module.exports = {
|
67
|
+
cache: true,
|
68
|
+
debug: !isProduction,
|
69
|
+
devtool: isProduction ? 'hidden-source-map' : 'eval-source-map',
|
70
|
+
context: path.join(__dirname, 'app/assets/webpack'),
|
71
|
+
entry: getEntries('app/assets/webpack/'),
|
72
|
+
output: {
|
73
|
+
path: outputPath,
|
74
|
+
publicPath: '/webpack-assets/',
|
75
|
+
filename: getOutputFilename('.js')
|
76
|
+
},
|
77
|
+
plugins: getPlugins(),
|
78
|
+
resolve: {
|
79
|
+
extensions: ['', '.js', '.scss', '.css', '.js.erb'],
|
80
|
+
root: [path.join(__dirname, 'app/assets/webpack')],
|
81
|
+
modulesDirectories: ['node_modules'],
|
82
|
+
fallback: __dirname
|
83
|
+
},
|
84
|
+
module: {
|
85
|
+
preLoaders: [
|
86
|
+
{ test: /\.erb$/, loader: 'uh-erb', exclude: /node_modules/ }
|
87
|
+
],
|
88
|
+
loaders: [
|
89
|
+
{ test: /\.js(\.erb)?$/, loader: 'babel', exclude: /node_modules/ },
|
90
|
+
{ test: /\.css$/, loaders: ['style', 'css?sourceMap', 'postcss'], exclude: /node_modules/ },
|
91
|
+
{
|
92
|
+
test: /\.scss/,
|
93
|
+
loaders: ['style', 'css?sourceMap', 'postcss', 'sass'],
|
94
|
+
exclude: /node_modules/
|
95
|
+
},
|
96
|
+
{ test: /\.(jpg|svgz|png|svg)$/, loader: 'file?name=[path][name]-[hash].[ext]' }
|
97
|
+
]
|
98
|
+
},
|
99
|
+
postcss: [autoprefixer],
|
100
|
+
devServer: {
|
101
|
+
outputPath: outputPath,
|
102
|
+
stats: {
|
103
|
+
hash: false,
|
104
|
+
version: false,
|
105
|
+
timings: true,
|
106
|
+
assets: false,
|
107
|
+
chunks: false,
|
108
|
+
children: false
|
109
|
+
},
|
110
|
+
port: WEBPACK_PORT
|
111
|
+
}
|
112
|
+
};
|
@@ -27,7 +27,7 @@ module RailsExternalAssets
|
|
27
27
|
@manifest_file = 'public/external-assets/manifest.json'
|
28
28
|
@sprockets_directives = [
|
29
29
|
{ mime_type: 'application/javascript', comments: ['//', ['/*', '*/']] },
|
30
|
-
{ mime_type: '
|
30
|
+
{ mime_type: 'text/css', comments: ['//', ['/*', '*/']] }
|
31
31
|
]
|
32
32
|
@build_script = 'echo "You did not define a build script"'
|
33
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_external_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Lehman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -71,6 +71,73 @@ files:
|
|
71
71
|
- Rakefile
|
72
72
|
- bin/console
|
73
73
|
- bin/setup
|
74
|
+
- examples/webpack/.babelrc
|
75
|
+
- examples/webpack/.env
|
76
|
+
- examples/webpack/.gitignore
|
77
|
+
- examples/webpack/Gemfile
|
78
|
+
- examples/webpack/Gemfile.lock
|
79
|
+
- examples/webpack/README.md
|
80
|
+
- examples/webpack/Rakefile
|
81
|
+
- examples/webpack/app/assets/images/.keep
|
82
|
+
- examples/webpack/app/assets/javascripts/application.js
|
83
|
+
- examples/webpack/app/assets/stylesheets/application.css
|
84
|
+
- examples/webpack/app/assets/webpack/ColorConverter/index.js
|
85
|
+
- examples/webpack/app/assets/webpack/ColorConverter/index.scss
|
86
|
+
- examples/webpack/app/assets/webpack/ColorConverter/initializer.js
|
87
|
+
- examples/webpack/app/assets/webpack/logger.js
|
88
|
+
- examples/webpack/app/controllers/application_controller.rb
|
89
|
+
- examples/webpack/app/controllers/concerns/.keep
|
90
|
+
- examples/webpack/app/helpers/application_helper.rb
|
91
|
+
- examples/webpack/app/mailers/.keep
|
92
|
+
- examples/webpack/app/models/.keep
|
93
|
+
- examples/webpack/app/models/concerns/.keep
|
94
|
+
- examples/webpack/app/views/application/index.html.erb
|
95
|
+
- examples/webpack/app/views/layouts/application.html.erb
|
96
|
+
- examples/webpack/bin/bundle
|
97
|
+
- examples/webpack/bin/rails
|
98
|
+
- examples/webpack/bin/rake
|
99
|
+
- examples/webpack/bin/setup
|
100
|
+
- examples/webpack/bin/spring
|
101
|
+
- examples/webpack/config.ru
|
102
|
+
- examples/webpack/config/application.rb
|
103
|
+
- examples/webpack/config/boot.rb
|
104
|
+
- examples/webpack/config/database.yml
|
105
|
+
- examples/webpack/config/environment.rb
|
106
|
+
- examples/webpack/config/environments/development.rb
|
107
|
+
- examples/webpack/config/environments/production.rb
|
108
|
+
- examples/webpack/config/environments/test.rb
|
109
|
+
- examples/webpack/config/initializers/assets.rb
|
110
|
+
- examples/webpack/config/initializers/backtrace_silencers.rb
|
111
|
+
- examples/webpack/config/initializers/cookies_serializer.rb
|
112
|
+
- examples/webpack/config/initializers/filter_parameter_logging.rb
|
113
|
+
- examples/webpack/config/initializers/inflections.rb
|
114
|
+
- examples/webpack/config/initializers/mime_types.rb
|
115
|
+
- examples/webpack/config/initializers/rails_external_assets.rb
|
116
|
+
- examples/webpack/config/initializers/session_store.rb
|
117
|
+
- examples/webpack/config/initializers/wrap_parameters.rb
|
118
|
+
- examples/webpack/config/locales/en.yml
|
119
|
+
- examples/webpack/config/routes.rb
|
120
|
+
- examples/webpack/config/secrets.yml
|
121
|
+
- examples/webpack/db/seeds.rb
|
122
|
+
- examples/webpack/lib/assets/.keep
|
123
|
+
- examples/webpack/lib/tasks/.keep
|
124
|
+
- examples/webpack/log/.keep
|
125
|
+
- examples/webpack/package.json
|
126
|
+
- examples/webpack/public/404.html
|
127
|
+
- examples/webpack/public/422.html
|
128
|
+
- examples/webpack/public/500.html
|
129
|
+
- examples/webpack/public/favicon.ico
|
130
|
+
- examples/webpack/public/robots.txt
|
131
|
+
- examples/webpack/test/controllers/.keep
|
132
|
+
- examples/webpack/test/fixtures/.keep
|
133
|
+
- examples/webpack/test/helpers/.keep
|
134
|
+
- examples/webpack/test/integration/.keep
|
135
|
+
- examples/webpack/test/mailers/.keep
|
136
|
+
- examples/webpack/test/models/.keep
|
137
|
+
- examples/webpack/test/test_helper.rb
|
138
|
+
- examples/webpack/vendor/assets/javascripts/.keep
|
139
|
+
- examples/webpack/vendor/assets/stylesheets/.keep
|
140
|
+
- examples/webpack/webpack.config.js
|
74
141
|
- lib/rails_external_assets.rb
|
75
142
|
- lib/rails_external_assets/asset_finder.rb
|
76
143
|
- lib/rails_external_assets/configuration.rb
|
@@ -103,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
170
|
version: '0'
|
104
171
|
requirements: []
|
105
172
|
rubyforge_project:
|
106
|
-
rubygems_version: 2.
|
173
|
+
rubygems_version: 2.6.6
|
107
174
|
signing_key:
|
108
175
|
specification_version: 4
|
109
176
|
summary: Use external assets, those built outside of Sprockets' asset pipeline, in
|