forked from obonneau/create-ipx-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
57 lines (52 loc) · 1.35 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
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin').CleanWebpackPlugin;
const CopyPlugin = require('copy-webpack-plugin');
const JoinResourcesPlugin = require('./plugins/join-resources');
const AssembleIPXTemplatePlugin = require('./plugins/assemble-template');
const srcPath = path.resolve(__dirname, 'src');
const distPath = path.resolve(__dirname, 'dist');
module.exports = () => {
const plugins = buildPlugins();
return {
mode: 'production',
entry: {
ipx: './src/ipx.js',
},
output: {
filename: '[name].js',
path: distPath,
},
devServer: {
contentBase: distPath,
writeToDisk: true
},
plugins
};
}
function buildPlugins() {
return [
new CleanWebpackPlugin(),
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, 'templates/index.html'),
to: distPath
},
{
from: path.resolve(srcPath, 'ipx.html'),
to: distPath
}, {
from: path.resolve(srcPath, 'ipx.css'),
to: distPath
}]
}),
new JoinResourcesPlugin({
htmlFileName: path.resolve(distPath, 'ipx.html'),
css: [path.resolve(distPath, 'ipx.css')],
js: [path.resolve(distPath, 'ipx.js')],
}),
new AssembleIPXTemplatePlugin({
ipxHtmlFileName: path.join(distPath, 'ipx.html')
})
]
}