-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.common.js
60 lines (59 loc) · 2.12 KB
/
webpack.common.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
/**
* Webpack common configuration.
* it:
* - Define the app entry point (./src) -> Where webpack will start compiling/bundling
* - Define where assets will be served at by our webserver (static/)
* - Clean previous build on each build
* - Generates the index.html file automatically by injecting bundled assets in it (css, js)
* - Allow to load html files as strings in js code (i.e: import htmlString from './myHtmlFile.html)
* - Allow to automatically generates the dependencies injection for angularJS components annotated with
* `'ngInject';` or `@ngInject` in comments. See https://docs.angularjs.org/guide/di
*/
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: { app: 'app.js' },
output: {
// Path where bundled files will be output
path: path.resolve(__dirname, 'static'),
// Path at which output assets will be served
publicPath: 'static/'
},
// Just for build speed improvement
resolve: { symlinks: false},
plugins: [
// Clean before build
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
// Path where the file will be generated (appended to output.path)
filename: '../index.html',
// index.html template file location
template: 'src/index.html',
// We manually inject css and js files in our template
inject: false
// favicon: 'assets/img/favicon.ico'
})
],
module: {
rules: [
// Automatically generates $inject array for angularJS components annotated with:
// 'ngInject';
// or commented with /**@ngInject */
{
test: /\.js$/,
exclude: /node_modules\/(?!(hslayers-ng)\/).*/,
use: [
{
loader: 'babel-loader',
options: {
// Babel syntax dynamic import plugin allow babel to correctly parse js files
// using webpack dynamic import expression (i.e import('angular').then(...))
plugins: ['angularjs-annotate', '@babel/plugin-syntax-dynamic-import']
}
}
]
}
]
}
};