1 | const path = require('path');
|
2 | const webpack = require('webpack');
|
3 |
|
4 | const base = {
|
5 | devtool: 'cheap-module-source-map',
|
6 | module: {
|
7 | rules: [
|
8 | {
|
9 | include: [
|
10 | path.resolve('src')
|
11 | ],
|
12 | test: /\.js$/,
|
13 | loader: 'babel-loader',
|
14 | options: {
|
15 | presets: ['es2015']
|
16 | }
|
17 | }
|
18 | ]
|
19 | },
|
20 | plugins: [
|
21 | new webpack.optimize.UglifyJsPlugin({
|
22 | include: /\.min\.js$/,
|
23 | minimize: true,
|
24 | sourceMap: true
|
25 | })
|
26 | ]
|
27 | };
|
28 |
|
29 | module.exports = [
|
30 |
|
31 | Object.assign({}, base, {
|
32 | target: 'web',
|
33 | entry: {
|
34 | 'scratch-storage': './src/index.js',
|
35 | 'scratch-storage.min': './src/index.js'
|
36 | },
|
37 | output: {
|
38 | library: 'ScratchStorage',
|
39 | libraryTarget: 'umd',
|
40 | path: path.resolve('dist', 'web'),
|
41 | filename: '[name].js'
|
42 | }
|
43 | }),
|
44 |
|
45 |
|
46 | Object.assign({}, base, {
|
47 | target: 'node',
|
48 | entry: {
|
49 | 'scratch-storage': './src/index.js'
|
50 | },
|
51 | output: {
|
52 | library: 'ScratchStorage',
|
53 | libraryTarget: 'commonjs2',
|
54 | path: path.resolve('dist', 'node'),
|
55 | filename: '[name].js'
|
56 | }
|
57 | })
|
58 | ];
|