1 | const path = require('path')
|
2 | const webpack = require('webpack')
|
3 | const {
|
4 | addPlugins,
|
5 | babel,
|
6 | css,
|
7 | createConfig,
|
8 | customConfig,
|
9 | entryPoint,
|
10 | env,
|
11 | sass,
|
12 | match,
|
13 | setOutput,
|
14 | sourceMaps,
|
15 | uglify,
|
16 | } = require('webpack-blocks')
|
17 |
|
18 | const pkg = require('./package.json')
|
19 |
|
20 | module.exports = createConfig([
|
21 | entryPoint('./src/index.js'),
|
22 |
|
23 | setOutput({
|
24 | filename: 'index.js',
|
25 | path: path.resolve('./build'),
|
26 | libraryTarget: 'umd',
|
27 | }),
|
28 |
|
29 | babel(),
|
30 |
|
31 | match('*.css', [
|
32 | env('development', [
|
33 | css({ modules: true, localIdentName: '[local]-[hash:base64:5]' }),
|
34 | ]),
|
35 | env('production', [
|
36 | css({ modules: true, localIdentName: '[hash:base64:5]', minimize: true }),
|
37 | ]),
|
38 | ]),
|
39 |
|
40 | match('*.scss', [
|
41 | env('development', [
|
42 | sass(),
|
43 | css({ modules: true, localIdentName: '[local]-[hash:base64:5]' }),
|
44 | ]),
|
45 | env('production', [
|
46 | sass(),
|
47 | css({ modules: true, localIdentName: '[hash:base64:5]', minimize: true }),
|
48 | ]),
|
49 | ]),
|
50 |
|
51 | env('development', [sourceMaps()]),
|
52 |
|
53 | env('production', [
|
54 | uglify(),
|
55 | addPlugins([
|
56 | new webpack.BannerPlugin({
|
57 | banner: `${pkg.name} v${
|
58 | pkg.version
|
59 | } (https://procore.github.io/core/latest/react)\nCopyright (c) 2016 Procore Technologies, Inc.`,
|
60 | }),
|
61 | ]),
|
62 | ]),
|
63 |
|
64 | customConfig({
|
65 | externals: { react: 'umd react', 'react-dom': 'umd react-dom' },
|
66 | }),
|
67 | ])
|