forked from fex-team/fit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.publish.js
executable file
·81 lines (71 loc) · 2.1 KB
/
webpack.publish.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
var webpack = require('webpack')
var path = require('path')
var resolve = require('./resolve.js')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var _ = require('lodash')
var fs = require('fs')
var args = process.argv.slice(2)
if (args.length === 0) {
console.error(
'you did not pass any commands, did you mean to run `updator push` ?'
)
process.exit(1)
}
var modulePath = args[0]
var modulePackageJSON = JSON.parse(fs.readFileSync(path.resolve(modulePath, 'package.json')).toString())
var alias = {}
for (var key in resolve.alias) {
alias[key] = true
}
var outputPath = path.resolve(modulePath, 'dist')
webpack({
entry: [
path.resolve(modulePath, 'src', 'index.js')
],
output: {
path: outputPath,
filename: 'index.js',
library: modulePackageJSON.name,
libraryTarget: 'umd'
},
externals: Object.assign({
'react': true,
'react-dom': true,
'jquery': true,
'classnames': true,
'lodash': true,
'bootstrap': true,
'react-router': true,
'flux': true,
'antd': true
}, alias),
module: {
loaders: [
{
test: /\.js?$/,
exclude: /node_modules/,
loaders: ['babel', 'html-path-loader']
}, {
test: /\.(css)$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
}, {
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!sass-loader')
}, {
test: /\.(png|jpg)$/,
exclude: /node_modules/,
loader: 'url?limit=3000&name=img/[hash:8].[name].[ext]'
}, {
test: /\.(woff|woff2|ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url?limit=3000&name=font/[hash:8].[name].[ext]'
}, {
test: /\.json$/,
loader: 'json-loader'
}
]
},
plugins: [
new ExtractTextPlugin('style.css')
]
}, function (err, stats) {
})