-
Notifications
You must be signed in to change notification settings - Fork 0
/
shared.js
80 lines (69 loc) · 1.78 KB
/
shared.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Note: You must restart bin/webpack-watcher for changes to take effect
const webpack = require('webpack')
const path = require('path')
const process = require('process')
const glob = require('glob')
const extname = require('path-complete-extname')
var ExtractTextPlugin = require('extract-text-webpack-plugin');
"use strict";
var distDir = process.env.WEBPACK_DIST_DIR
if (distDir === undefined) {
distDir = 'packs'
}
const config = {
entry: glob.sync(path.join('app', 'javascript', 'packs', '*.js*')).reduce(
(map, entry) => {
const basename = path.basename(entry, extname(entry))
const localMap = map
localMap[basename] = path.resolve(entry)
return localMap
}, {}
),
output: { filename: '[name].js', path: path.resolve('public', distDir) },
module: {
rules: [
{ test: /\.coffee(\.erb)?$/, loader: 'coffee-loader' },
{
test: /\.jsx?(\.erb)?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
presets: [
'react',
['latest', { es2015: { modules: false } }]
]
}
},
{
test: /\.(sass|scss)$/,
loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader'])
},
{
test: /\.erb$/,
enforce: 'pre',
exclude: /node_modules/,
loader: 'rails-erb-loader',
options: {
runner: 'DISABLE_SPRING=1 bin/rails runner'
}
}
]
},
plugins: [
new webpack.EnvironmentPlugin(Object.keys(process.env))
],
resolve: {
extensions: ['.js', '.coffee'],
modules: [
path.resolve('app/javascript'),
path.resolve('node_modules')
]
},
resolveLoader: {
modules: [path.resolve('node_modules')]
}
}
module.exports = {
distDir,
config
}