const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = (env = {}) => ({
entry: ['./src/main.scss', './src/main.jsx'],
output: {
path: path.resolve(__dirname, `./html/${env.branch || 'master'}`),
filename: 'kt-infoscreen.js',
library: 'ktInfoScreen',
libraryExport: 'default',
libraryTarget: 'umd',
},
mode: env.mode || 'development',
devtool: 'eval',
resolve: {
extensions: ['.js', '.jsx', '.css', '.sass', '.scss'],
},
plugins: [
new CopyWebpackPlugin([{
from: 'dev/static/',
to: 'static/'
},
'dev/index.html',
]),
],
module: {
rules: [{
enforce: 'pre',
test: [/\.js$/, /\.jsx$/],
exclude: /node_modules/,
loader: 'eslint-loader',
options: {
failOnError: env === 'production',
},
},
{
test: [/\.js$/, /\.jsx$/],
exclude: /node_modules/,
use: 'babel-loader',
},
{
test: [/\.css$/g, /\.sass$/g, /\.scss$/g],
use: [{
loader: 'css-hot-loader',
},
{
loader: 'file-loader',
options: {
name: 'kt-infoscreen.css',
},
},
{
loader: 'sass-loader',
options: {
includePaths: ['./node_modules'],
outputStyle: env === 'production' ? 'compressed' : 'nested',
},
},
],
},
],
},
watchOptions: {
poll: 1500,
},
devServer: {
contentBase: path.resolve(__dirname, './dev/'),
watchContentBase: true,
disableHostCheck: true,
host: '127.0.0.1',
port: 3999,
// public: process.env.webpack_public_address || null,
overlay: true,
},
});