-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
70 lines (64 loc) · 1.95 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
const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const process = require('process');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const prod = process.argv.indexOf('-p') !== -1;
if (!process.env.FIREBASE_PROJECT) {
console.error('FIREBASE_PROJECT env var not set');
process.exit(1);
}
module.exports = {
entry: './src/main.ts',
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{
loader: 'ts-loader',
},
// {
// loader: 'ngc-webpack',
// options: {
// disable: true // !prod,
// }
// },
],
exclude: /node_modules/
},
{
test: /\.scss$/,
use: ['raw-loader', 'sass-loader'],
},
{
test: /\.html$/,
use: 'raw-loader',
},
]
},
resolve: {
extensions: [".tsx", ".ts", ".js"]
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
plugins: [
new HtmlWebpackPlugin({ template: './index.html', hash: true }),
new CopyWebpackPlugin([{ from: 'img', to: 'img' }]),
new webpack.DefinePlugin({
NODE_ENV: JSON.stringify(prod ? 'production' : 'development'),
FIREBASE_PROJECT: JSON.stringify(process.env.FIREBASE_PROJECT),
}),
new webpack.ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows
/angular([\\\/])core/,
root('./src'), // location of your src
{ }
)
].filter(Boolean),
};
function root(__path) {
return path.join(__dirname, __path);
}