-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.dist.config.js
74 lines (68 loc) · 1.78 KB
/
webpack.dist.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
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const path = require('path')
const SVGSpritemapPlugin = require('svg-spritemap-webpack-plugin')
const {NODE_ENV} = process.env
const DIST_PATH = path.join(__dirname, 'dist')
const IS_PRODUCTION = NODE_ENV === 'production'
const CSS_FILE_NAME = IS_PRODUCTION
? `react-frost-core.min.css`
: `react-frost-core.css`
const JS_FILE_NAME = IS_PRODUCTION
? `react-frost-core.min.js`
: `react-frost-core.js`
function getPlugins() {
const plugins = [
new SVGSpritemapPlugin({
filename: 'frost-pack.svg',
src: 'src/svgs/**/*.svg',
}),
new ExtractTextPlugin(CSS_FILE_NAME),
]
return plugins
}
module.exports = {
devtool: IS_PRODUCTION ? 'eval' : 'source-map',
entry: path.resolve('src', 'index.js'),
externals: ['grammatic', 'react', 'react-dom', 'react-domlistener'],
mode: IS_PRODUCTION ? 'production' : 'development',
module: {
rules: [
{
exclude: [/node_modules/],
test: /\.css$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: {
importLoaders: 1,
minimize: IS_PRODUCTION,
sourceMap: true,
},
},
'postcss-loader',
],
}),
},
{
exclude: [/node_modules/],
loaders: [
'file-loader?hash=sha512&digest=hex&name=assets/[hash].[ext]',
],
test: /\.(gif|jpe?g|png|svg)$/,
},
{
exclude: [/node_modules/],
loaders: ['babel-loader'],
test: /\.js$/,
},
],
},
output: {
path: DIST_PATH,
filename: JS_FILE_NAME,
library: `reactFrostCore`,
libraryTarget: 'umd',
},
plugins: getPlugins(),
}