Completed
Push — master ( 71718d...90a3d2 )
by Rain
04:31
created

webpack.config.builder.js   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 91
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 0
c 0
b 0
f 0
nc 2
dl 0
loc 91
rs 10
noi 2
wmc 1
mnd 0
bc 1
fnc 1
bpm 1
cpm 1
1
2
var
3
	path = require('path'),
4
	webpack = require('webpack'),
5
	devPath = path.resolve(__dirname, 'dev'),
6
	CopyWebpackPlugin = require('copy-webpack-plugin'),
7
	WebpackNotifierPlugin = require('webpack-notifier'),
8
	loose = true;
9
10
process.noDeprecation = true;
11
module.exports = function(publicPath, pro) {
12
	return {
13
		entry: {
14
			'js/boot': path.join(__dirname, 'dev', 'boot.js'),
15
			'js/app': path.join(__dirname, 'dev', 'app.js'),
16
			'js/admin': path.join(__dirname, 'dev', 'admin.js')
17
		},
18
		output: {
19
			pathinfo: true,
20
			path: path.join(__dirname, 'rainloop', 'v', '0.0.0', 'static'),
21
			filename: '[name].js',
22
			publicPath: publicPath || 'rainloop/v/0.0.0/static/'
23
		},
24
		plugins: [
25
			// new webpack.optimize.ModuleConcatenationPlugin(),
26
			new webpack.DefinePlugin({
27
				'RL_COMMUNITY': !pro,
28
				'process.env': {
29
					NODE_ENV: '"production"'
30
				}
31
			}),
32
			new WebpackNotifierPlugin(),
33
			new CopyWebpackPlugin([
34
				{from: 'node_modules/openpgp/dist/openpgp.min.js', to: 'js/min/openpgp.min.js'},
35
				{from: 'node_modules/openpgp/dist/openpgp.worker.min.js', to: 'js/min/openpgp.worker.min.js'}
36
			])
37
		],
38
		resolve: {
39
			modules: [devPath, 'node_modules'],
40
			extensions: ['.js'],
41
			alias: {
42
				'Opentip$': __dirname  + '/dev/External/Opentip.js',
43
				'ko$': __dirname  + '/dev/External/ko.js'
44
			}
45
		},
46
		module: {
47
			rules: [
48
				{
49
					test: /\.js$/,
50
					loader: 'babel-loader',
51
					include: [devPath],
52
					options: {
53
						cacheDirectory: true,
54
						presets: [['env', {
55
							loose: loose,
56
							modules: false,
57
							targets: {
58
								browsers: ['last 3 versions', 'ie >= 9', 'firefox esr']
59
							}
60
						}], 'stage-0'],
61
						plugins: ['transform-runtime', 'transform-decorators-legacy']
62
					}
63
				},
64
				{
65
					test: /\.(html|css)$/,
66
					loader: 'raw-loader',
67
					include: [devPath]
68
				},
69
				{
70
					test: /\.json$/,
71
					loader: 'json-loader',
72
					include: [devPath]
73
				}
74
			]
75
		},
76
		externals: {
77
			'window': 'window',
78
			'progressJs': 'window.progressJs',
79
			'moment': 'window.moment',
80
			'ifvisible': 'window.ifvisible',
81
			'crossroads': 'window.crossroads',
82
			'hasher': 'window.hasher',
83
			'Jua': 'window.Jua',
84
			'Autolinker': 'window.Autolinker',
85
			'ssm': 'window.ssm',
86
			'key': 'window.key',
87
			'_': 'window._',
88
			'qr': 'window.qr',
89
			'$': 'window.jQuery'
90
		}
91
	};
92
};
93