/
webpack.config.js
78 lines (71 loc) · 2.45 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
var path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyPlugin = require('copy-webpack-plugin');
var config = {
mode: 'production',
entry: './src/WebBridge.ts',
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '',
filename: 'javascripts/WebBridge.bundle.js'
},
resolve: {
extensions: [ '.tsx', '.ts', '.js' ]
},
module: {
rules: [
// all files with a `.ts` or `.tsx` extension will be handled by `ts-loader`
{ test: /\.tsx?$/, use: "ts-loader", exclude: ['/node_modules/', '/tests']},
{ test: /\.css$/, use: [MiniCssExtractPlugin.loader, 'css-loader'] },
{ test: /\.pug$/, loader: 'pug-loader' },
{ test: /\.(png|jpg)$/, loader: 'url-loader'},
{ test: /\.json$/, loader: 'json-loader'}
]
},
devServer: {
contentBase: path.join(__dirname, 'dist'),
port: 8080,
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
favicon: './images/favicon.ico',
template: './templates/index.pug',
}),
new MiniCssExtractPlugin({
filename: 'stylesheets/styles.css'
}),
]
}
module.exports = (env, argv) => {
var basicFilesToCopy = [
{ from: './images/*.png', to: './' }, // XXX TODO not only png
{ from: './libs/sidebars.js', to: 'javascripts'},
]
if (argv.mode === 'development') {
config.devtool = "inline-source-map";
config.plugins.push(
new CopyPlugin([
...basicFilesToCopy,
{ from: './translations/translations_local.json', to: 'translations.json' },
]),
)
}
if (argv.mode === 'production' && argv.eisenv === 'staging') {
config.plugins.push(
new CopyPlugin([
...basicFilesToCopy,
{ from: './translations/translations_staging.json', to: 'translations.json' }, // XXX TODO Replace for prod in other branch
]),
)
} else if (argv.mode === 'production' && argv.eisenv === 'production') {
config.plugins.push(
new CopyPlugin([
...basicFilesToCopy,
{ from: './translations/translations_prod.json', to: 'translations.json' }, // XXX TODO Replace for prod in other branch
]),
)
}
return config;
};