-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
65 lines (58 loc) · 1.82 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
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
function resolve(filePath) {
return path.isAbsolute(filePath) ? filePath : path.join(__dirname, filePath);
}
var cfg = {
projectPath: './Demo/',
index: './Demo/index.html',
entry: './fable_output/Main.js',
output: './dist'
}
// The HtmlWebpackPlugin allows us to use a template for the index.html page
// and automatically injects <script> or <link> tags for generated bundles.
var htmlPlugin =
new HtmlWebpackPlugin({
filename: 'index.html',
template: resolve(cfg.index)
});
// Configuration for webpack-dev-server
var devServer = {
host: 'localhost',
port: 8088,
hot: true
};
// If we're running the webpack-dev-server, assume we're in development mode
var isProduction = !process.argv.find(v => v.indexOf('webpack-dev-server') !== -1);
var environment = isProduction ? 'production' : 'development';
process.env.NODE_ENV = environment;
console.log('Bundling for ' + environment + '...');
module.exports = {
entry: { app: resolve(cfg.entry) },
output: {
path: resolve(cfg.output),
filename: isProduction ? '[name].[contenthash].js' : '[name].js',
clean: true
},
devtool: isProduction ? undefined : 'eval-source-map',
resolve: {
alias: {
Project: path.resolve(__dirname, cfg.projectPath)
},
symlinks: false
}, // See https://github.com/fable-compiler/Fable/issues/1490
mode: environment,
plugins: [htmlPlugin],
optimization: { splitChunks: { chunks: 'all' } },
devServer: devServer,
module: {
rules: [
{
test: /\.js$/,
enforce: "pre",
exclude: /node_modules|fable_modules/,
use: ["source-map-loader"]
}
]
}
};