UNPKG

2.97 kBJavaScriptView Raw
1const path = require('path');
2const CopyPlugin = require('copy-webpack-plugin');
3const WriteFilePlugin = require('write-file-webpack-plugin');
4const CleanWebpackPlugin = require('clean-webpack-plugin');
5
6module.exports = env => {
7
8 return {
9 context: __dirname,
10 entry: {
11 simulator: __dirname + "/src/display-app/index.tsx",
12 "widget-host": __dirname + "/src/widget-host/index.tsx",
13 },
14 output: {
15 path: path.resolve(__dirname, "build"),
16 filename: "[name].app.js"
17 },
18 devServer: {
19 contentBase: path.resolve(__dirname, "build"),
20 port: 5555
21 },
22 plugins: [
23 new CopyPlugin([
24 {from: __dirname + '/pages/*.html', to: __dirname + '/build/[name].[ext]'},
25 {from: env.bundleFile, to: __dirname + '/build/test-widget.bundle.js'},
26 {from: env.mockFile, to: __dirname + '/build/host-mock.bundle.js'},
27 {
28 from: require.resolve('@talentsoft-opensource/integration-dll/dist/integration.dll.js'),
29 to: __dirname + '/build/integration.dll.js'
30 },
31 {
32 from: require.resolve('@talentsoft-opensource/display-tool-widget-mock/dist/main.bundle.js'),
33 to: __dirname + '/build/mock-widget.bundle.js'
34 }
35 ]),
36 new WriteFilePlugin(),
37 new CleanWebpackPlugin(),
38 ],
39 resolve: {
40 extensions: ['.ts', '.js', '.tsx']
41 },
42 module: {
43 rules: [
44 {
45 test: /\.less$/,
46 use: [{
47 loader: 'style-loader' // creates style nodes from JS strings
48 }, {
49 loader: 'css-loader' // translates CSS into CommonJS
50 }, {
51 loader: 'less-loader', // compiles Less to CSS
52 options: {
53 importLoaders: 1,
54 paths: [path.resolve(__dirname + '../../../', 'node_modules')],
55
56 }
57 }]
58 },
59 {
60 test: /\.tsx?$/,
61 use: 'ts-loader',
62 },
63 {
64 test: /\.(woff|woff2|eot|ttf|svg)$/,
65 include: /node_modules/,
66 loader: "file-loader",
67 options: {
68 name: "dist/assets/fonts/[name].[ext]",
69 publicPath: ""
70 }
71 },
72 {
73 test: /\.(svg|png|jpg|gif)$/,
74 loader: "file-loader",
75 options: {
76 name: "assets/images/[name].[ext]",
77 publicPath: ""
78 }
79 },
80 ]
81 }
82 }
83};
\No newline at end of file