-
Notifications
You must be signed in to change notification settings - Fork 188
/
Copy pathwebpack-docs.config.js
108 lines (96 loc) · 2.72 KB
/
webpack-docs.config.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* eslint-env node */
/* eslint-disable no-var */
/* eslint-disable modules/no-cjs */
/* eslint-disable camelcase */
var path = require('path');
var webpack = require('webpack');
var webpackConfigMerger = require('webpack-config-merger');
var webpackConfig = require('./webpack.config');
var AnyBarWebpackPlugin = require('anybar-webpack');
var progressPlugin = require('./tools/progress-webpack-plugin');
var isServer = process.argv.indexOf('--server') !== -1;
var nodeModulesPath = path.join(__dirname, 'node_modules');
var sitePath = [
path.join(__dirname, 'docs'),
path.join(__dirname, 'site')
];
var publicPath = '/assets/';
var config = require('./package.json').config;
var hubOptPath = process.argv.indexOf('--hub') + 1;
var hubOpt = hubOptPath && process.argv[hubOptPath];
var hub = hubOpt || process.env.npm_package_config_hub || config.hub;
var hubUri = hub in config.hubs ? config.hubs[hub] : hub;
var productionClientId = '81a0bffb-6d0f-4a38-b93a-0a4d1e567698';
var useProductionClientId = hubUri === config.hubs.production || hubUri === config.hubs.default;
var host = process.env.npm_package_config_host || config.host;
var hubServerConfig = {
serverUri: hubUri,
client_id: useProductionClientId ? productionClientId : '0-0-0-0-0',
request_credentials: 'skip',
redirect_uri: 'http://' + host + ':' + config.port + '/'
};
var hubProductionConfig = {
serverUri: config.hubs.production,
client_id: productionClientId,
request_credentials: 'skip',
redirect_uri: 'http://ring-ui.github.io'
};
var docsWebpackConfig = webpackConfigMerger(webpackConfig, {
entry: {
index: './site/'
},
resolve: {
alias: {
'ring-ui': __dirname
}
},
module: {
loaders: [
{
test: /\.scss$/,
include: sitePath,
loaders: [
'style',
'css',
'postcss?pack=ring-ui',
'sass?outputStyle=expanded'
]
},
{
test: /\.css$/,
include: nodeModulesPath,
loaders: [
'style',
'css'
]
},
{
test: /\.js$/,
include: sitePath,
loader: 'babel'
}
]
},
devtool: isServer ? 'eval' : '#source-map',
debug: isServer,
output: {
path: path.resolve(__dirname, 'docs', 'assets'),
pathinfo: isServer,
filename: '[name].js',
publicPath: publicPath // serve HMR update json's properly
},
plugins: [
new webpack.DefinePlugin({
hubConfig: JSON.stringify(isServer ? hubServerConfig : hubProductionConfig)
})
]
});
if (isServer) {
docsWebpackConfig.plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new AnyBarWebpackPlugin(),
progressPlugin
);
}
module.exports = docsWebpackConfig;