-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
78 lines (75 loc) · 2.38 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
/* webpack.config.js */
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const Clean = require('clean-webpack-plugin')
const path = require('path')
const setupServerMockup = require('./demo/serverMockup')
module.exports = {
// Tell Webpack which file kicks off our app.
entry: {
index: path.resolve(__dirname, 'demo/index.js'),
},
// Tell Weback to output our bundle to ./dist/bundle.js
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'build')
},
// 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: [ 'node_modules'],
extensions: ['.ts', '.tsx', '.js', '.jsx', '.html'],
alias: { '@polymer/iron-selector': path.resolve(__dirname, 'node_modules/@taktik/iron-selector-meta-shift')}
},
// These rules tell Webpack how to process different module types.cd ..
// Remember, *everything* is a module in Webpack. That includes
// CSS, and (thanks to our loader) HTML.
module: {
rules: [
{
// If you see a file that ends in .js, just send it to the babel-loader.
test: /\.js$/,
use: 'babel-loader'
},
{
test: /\.(gif|png|jpe?g|svg)$/i,
use: [
'file-loader',
{
loader: 'image-webpack-loader',
options: {
bypassOnDebug: true,
},
},
],
}
]
},
mode: "development",
plugins: [
// 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({
inject: false,
template: path.resolve(__dirname, 'demo/index.ejs')
}),
// This plugin will copy files over to ‘./dist’ without transforming them.
// That's important because the custom-elements-es5-adapter.js MUST
// remain in ES2015. We’ll talk about this a bit later :)
new CopyWebpackPlugin([{
from: path.resolve(__dirname, 'node_modules/@webcomponents/webcomponentsjs/*.js'),
to: 'webcomponentsjs/[name].[ext]'
}]),
new Clean(['build']),
],
devServer: {
contentBase: path.join(__dirname),
compress: true,
overlay: true,
port: 9011,
setup: setupServerMockup,
},
}