@talentsoft-opensource/widget-display-tool
Version:
Widget Simulator
75 lines (72 loc) • 2.55 kB
JavaScript
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const WriteFilePlugin = require('write-file-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = env => {
return {
context: __dirname,
entry: {
simulator: __dirname + "/src/display-app/index.tsx",
"widget-host": __dirname + "/src/widget-host/index.tsx",
},
output: {
path: path.resolve(__dirname, "build"),
filename: "[name].app.js"
},
devServer: {
contentBase: path.resolve(__dirname, "build"),
port: 5555
},
plugins: [
new CopyPlugin([
{from: __dirname + '/pages/*.html', to: __dirname + '/build/[name].[ext]'},
{from: env.bundleFile, to: __dirname + '/build/test-widget.bundle.js'},
{from: env.mockFile, to: __dirname + '/build/host-mock.bundle.js'},
{
from: require.resolve('@talentsoft-opensource/display-tool-widget-mock/dist/main.bundle.js'),
to: __dirname + '/build/mock-widget.bundle.js'
}
]),
new WriteFilePlugin(),
new CleanWebpackPlugin(),
],
resolve: {
extensions: ['.ts', '.js', '.tsx']
},
module: {
rules: [
{
test: /\.less$/,
use: [{
loader: 'style-loader' // creates style nodes from JS strings
}, {
loader: 'css-loader' // translates CSS into CommonJS
}, {
loader: 'less-loader', // compiles Less to CSS
}]
},
{
test: /\.tsx?$/,
use: 'ts-loader',
},
{
test: /\.(woff|woff2|eot|ttf|svg)$/,
include: /node_modules/,
loader: "file-loader",
options: {
name: "dist/assets/fonts/[name].[ext]",
publicPath: ""
}
},
{
test: /\.(svg|png|jpg|gif)$/,
loader: "file-loader",
options: {
name: "assets/images/[name].[ext]",
publicPath: ""
}
},
]
}
}
};