|
1 | | -const path = require('path') |
2 | | -const HtmlWebpackPlugin = require('html-webpack-plugin') |
| 1 | +const path = require('path'); |
| 2 | +const HtmlWebpackPlugin = require('html-webpack-plugin'); |
3 | 3 |
|
4 | | -// module.exports = [{ |
5 | | -module.exports = (env, args) => { |
6 | | - const production = args.mode === 'production' |
7 | | - return { |
8 | | - mode: args.mode || 'development', |
9 | | - entry: './src/index.ts', |
10 | | - output: { |
11 | | - path: path.join(__dirname, '/dist/'), |
12 | | - publicPath: '', |
13 | | - filename: production ? 'solid-ui.min.js' : 'solid-ui.js', |
14 | | - library: 'solid-ui', |
15 | | - libraryTarget: 'umd' |
16 | | - }, |
17 | | - plugins: [ |
18 | | - new HtmlWebpackPlugin() // plugin that creates in /lib the index.html that contains the webpack-bundle.js |
19 | | - ], |
20 | | - externals: { |
21 | | - fs: 'null', |
22 | | - 'node-fetch': 'fetch', |
23 | | - 'isomorphic-fetch': 'fetch', |
24 | | - xmldom: 'window', |
25 | | - 'text-encoding': 'TextEncoder', |
26 | | - 'whatwg-url': 'window', |
27 | | - '@trust/webcrypto': 'crypto' |
28 | | - }, |
29 | | - resolve: { |
30 | | - extensions: ['.ts', '.js'], |
31 | | - fallback: { path: false } |
32 | | - }, |
33 | | - devServer: { |
34 | | - static: './dist' |
35 | | - }, |
36 | | - devtool: 'source-map', |
37 | | - module: { |
38 | | - rules: [{ |
39 | | - test: /\.ts$/, |
40 | | - use: 'babel-loader', |
41 | | - exclude: /node_modules/ |
42 | | - }, { |
43 | | - test: /\.sparql$/i, |
44 | | - type: 'asset/source' |
45 | | - }, { |
46 | | - test: /\.ttl$/i, |
47 | | - type: 'asset/source' |
48 | | - }] |
49 | | - } |
| 4 | +const common = { |
| 5 | + entry: './src/index.ts', |
| 6 | + output: { |
| 7 | + path: path.join(__dirname, '/dist/'), |
| 8 | + publicPath: '', |
| 9 | + library: 'solid-ui', |
| 10 | + libraryTarget: 'umd' |
| 11 | + }, |
| 12 | + plugins: [ |
| 13 | + new HtmlWebpackPlugin() |
| 14 | + ], |
| 15 | + externals: { |
| 16 | + fs: 'null', |
| 17 | + 'node-fetch': 'fetch', |
| 18 | + 'isomorphic-fetch': 'fetch', |
| 19 | + xmldom: 'window', |
| 20 | + 'text-encoding': 'TextEncoder', |
| 21 | + 'whatwg-url': 'window', |
| 22 | + '@trust/webcrypto': 'crypto' |
| 23 | + }, |
| 24 | + resolve: { |
| 25 | + extensions: ['.ts', '.js'], |
| 26 | + fallback: { path: false } |
| 27 | + }, |
| 28 | + devServer: { |
| 29 | + static: './dist' |
| 30 | + }, |
| 31 | + devtool: 'source-map', |
| 32 | + module: { |
| 33 | + rules: [{ |
| 34 | + test: /\.ts$/, |
| 35 | + use: 'babel-loader', |
| 36 | + exclude: /node_modules/ |
| 37 | + }, { |
| 38 | + test: /\.sparql$/i, |
| 39 | + type: 'asset/source' |
| 40 | + }, { |
| 41 | + test: /\.ttl$/i, |
| 42 | + type: 'asset/source' |
| 43 | + }] |
50 | 44 | } |
51 | | -} |
| 45 | +}; |
| 46 | + |
| 47 | +const minified = { |
| 48 | + ...common, |
| 49 | + mode: 'production', |
| 50 | + output: { |
| 51 | + ...common.output, |
| 52 | + filename: 'solid-ui.min.js' |
| 53 | + }, |
| 54 | + optimization: { |
| 55 | + minimize: true |
| 56 | + } |
| 57 | +}; |
| 58 | + |
| 59 | +const unminified = { |
| 60 | + ...common, |
| 61 | + mode: 'development', |
| 62 | + output: { |
| 63 | + ...common.output, |
| 64 | + filename: 'solid-ui.js' |
| 65 | + }, |
| 66 | + optimization: { |
| 67 | + minimize: false |
| 68 | + } |
| 69 | +}; |
| 70 | + |
| 71 | +module.exports = [minified, unminified]; |
0 commit comments