-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathwebpack.config.js
More file actions
84 lines (81 loc) · 3.01 KB
/
Copy pathwebpack.config.js
File metadata and controls
84 lines (81 loc) · 3.01 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* webpack.config.js */
var HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
var path = require('path');
const CopyWebpackPlugin = require("copy-webpack-plugin");
module.exports = {
// Tell Webpack which file kicks off our app.
entry: path.resolve(__dirname,'./datasource-consysapi.js'),
// Tell Weback to output our bundle to ./dist/bundle.js
output: {
filename: 'bundle.datasource.consysapi.js',
path: path.resolve(__dirname, 'dist')
},
// Tell Webpack which directories to look in to resolve import statements.
// Normally Webpack will look in node_modules by default but since we’re overriding
// the property we’ll need to tell it to look there in addition to the
// bower_components folder.
resolve: {
modules: [
path.resolve(__dirname, 'node_modules'),
],
alias: {
'osh-js': path.resolve(__dirname, '../../../source')
}
},
// These rules tell Webpack how to process different module types.
// Remember, *everything* is a module in Webpack. That includes
// CSS, and (thanks to our loader) HTML.
module: {
rules: [
{
test: /\.(png|svg|jpg|gif)$/,
use: [
'file-loader',
],
},{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.worker\.js$/,
use: { loader: 'worker-loader', options: { name: 'WorkerName.[hash].js' } }
}
]
},
// Enable the Webpack dev server which will build, serve, and reload our
// project on changes.
devServer: {
contentBase: path.join(__dirname, 'dist'),
compress: true,
port: 9000,
hot: true,
index: 'datasource-consysapi.html',
https:true
},
devtool: 'source-map',
plugins: [
/**
* All files inside webpack's output.path directory will be removed once, but the
* directory itself will not be. If using webpack 4+'s default configuration,
* everything under <PROJECT_DIR>/dist/ will be removed.
* Use cleanOnceBeforeBuildPatterns to override this behavior.
*
* During rebuilds, all webpack assets that are not used anymore
* will be removed automatically.
*
* See `Options and Defaults` for information
*/
new CleanWebpackPlugin(),
// This plugin will generate an index.html file for us that can be used
// by the Webpack dev server. We can give it a template file (written in EJS)
// and it will handle injecting our bundle for us.
new HtmlWebpackPlugin({
filename: "datasource-consysapi.html",
template: path.resolve(__dirname, 'datasource-consysapi.html')
}),
new CopyWebpackPlugin([
{ from: path.resolve(__dirname,'data'), to: 'data'}
])
]
};