forked from Netflix/vector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
110 lines (108 loc) · 3.59 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
'use strict'
const webpack = require('webpack')
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const WebpackAutoInjectVersion = require('webpack-auto-inject-version')
let config = {
mode: 'development',
entry: {
javascript: './src/app/index.module.js'
},
output: {
path: path.join(__dirname, '/dist/'),
filename: 'scripts/bundle.js',
publicPath: ''
},
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre',
exclude: /node_modules/,
use: [
{ loader: 'eslint-loader', options: { envs: ['commonjs'] } },
]
},
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{ loader: 'babel-loader', options: { presets: [ 'es2015' ] } },
]
},
{
test: /\.html$/,
exclude: [
path.resolve(__dirname, 'src/index.html'),
],
use: [
{ loader: "ngtemplate-loader", query: { relativeTo: 'src/app/' } },
{ loader: "html-loader" }
]
},
{
test: /\.css$/,
use: [
{ loader: "style-loader" }, // creates style nodes from JS strings
{ loader: "css-loader" }, // translates CSS into CommonJS
]
},
{
test: /\.woff2?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: 'url-loader?name=fonts/[name].[ext]&limit=10000',
},
{
test: /\.(ttf|eot|svg|otf)(\?[\s\S]+)?$/,
use: 'file-loader?name=fonts/[name].[ext]',
},
{
test: /\.scss$/,
use: [
{ loader: "style-loader" }, // creates style nodes from JS strings
{ loader: "css-loader" }, // translates CSS into CommonJS
{ loader: "sass-loader" } // compiles Sass to CSS
]
}
]
},
resolve: {
alias: {
'lodash': 'lodash/lodash',
'angular-santize': 'angular-sanitize/angular-sanitize.js'
}
},
devtool: 'source-map',
plugins: [
// needs to go first to insert the file in js
new WebpackAutoInjectVersion({
components: {
AutoIncreaseVersion: false,
InjectAsComment: false,
InjectByTag: true
}
}),
// the html, which will have the bundle.js script tag injected
new HtmlWebpackPlugin({
template: 'src/index.html',
inject: 'head'
}),
// copy static assets
new CopyWebpackPlugin([
{ from: 'src/lib/d3-heatmap2', to: 'lib/d3-heatmap2' },
{ from: 'src/lib/d3-flame-graph', to: 'lib/d3-flame-graph' },
{ from: 'src/lib/d3v4.js', to: 'lib/d3v4.js' },
{ from: 'src/favicon.ico', to: 'favicon.ico' },
{ from: 'src/assets/images/vector_owl.png', to: 'assets/images/vector_owl.png' }
]),
// configure jquery, needed by angular and other components that assume jQuery or other strings
new webpack.ProvidePlugin({
$: 'jquery',
'jQuery': 'jquery',
'window.jQuery': 'jquery',
moment: 'moment',
'_': 'lodash'
}),
]
}
module.exports = config