forked from 4746/grapesjs-image-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
56 lines (51 loc) · 1.24 KB
/
webpack.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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const fs = require('fs');
let plugins = [];
let rules = [];
const isProduction = process.env.NODE_ENV === 'production';
if (isProduction) {
plugins.push(new HtmlWebpackPlugin({
template: fs.existsSync('index.html') ? 'index.html' : 'index.html',
inject: false,
minify: true,
compile: true
}));
} else {
const index = 'index.html';
const indexDev = '_' + index;
plugins.push(new HtmlWebpackPlugin({
template: fs.existsSync(indexDev) ? indexDev : index,
inject: false,
minify: false,
compile: false
}));
rules.push({
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
})
}
module.exports = {
entry: isProduction ? './dist/index.js' : './src/index.ts',
devtool: isProduction ? 'source-map' : 'inline-source-map',
devServer: {
contentBase: path.join(__dirname, 'dist'),
port: 8080,
publicPath: '/'
},
module: {
rules: rules
},
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
output: {
filename: 'index.js',
path: path.resolve(__dirname, 'dist'),
// publicPath: '/'
libraryTarget: 'umd',
},
// externals: {'grapesjs': 'grapesjs'},
plugins: plugins
};