Repository navigation
Expand file tree
/
Copy pathwebpack.common.js
More file actions
65 lines (64 loc) · 2.34 KB
/
Copy pathwebpack.common.js
File metadata and controls
65 lines (64 loc) · 2.34 KB
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
/**
* 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');
const hslPaths = require(path.join(__dirname, './node_modules/hslayers-ng/common_paths'));
module.exports = {
entry: { main: '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: true,
modules: [
path.join(__dirname),
path.join(__dirname, "./node_modules"),
path.resolve(path.join(__dirname, "./node_modules", "hslayers-ng"))
].concat(hslPaths.paths)},
plugins: [
// Clean before build
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
// Path where the file will be generated (appended to output.path)
filename: '../index.html',
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/,
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']
}
}
]
}
]
}
};