activator-oce-exporter
Version:
Extract Activator binder and convert it to valid OCE mono pacakge
91 lines (89 loc) • 2.33 kB
JavaScript
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const WriteFilePlugin = require('write-file-webpack-plugin');
module.exports = (env, argv) => {
const { mode, browser, port } = argv;
const isProduction = (mode && mode === 'production');
const isIe = (browser && browser === 'ie');
const targetBrowsers = isIe ? ['IE 11'] : ['last 2 Chrome versions', 'last 2 Firefox versions', 'last 2 iOS versions'];
const outputFile = isIe ? 'main-ie.js' : 'main.js';
return {
entry: {
main: './src/main.js',
},
output: {
filename: outputFile,
},
mode: 'development',
// from https://gist.github.com/mburakerman/629783c16acf5e5f03de60528d3139af
module: {
rules: [
{
test: /\.m?js$/,
// exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', {
targets: { browsers: targetBrowsers },
}],
],
},
},
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader',
],
},
{
// @todo: remove PNG from fonts!
test: /\.(woff(2)?|ttf|eot|svg|otf|png)(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/',
},
}],
},
{
test: /\.(js)$/,
exclude: [/node_modules/, /_vendor/, /dist/, /lib/],
loader: 'eslint-loader',
options: {
// eslint options (if necessary)
},
},
{
test: /\.(html)$/,
use: {
loader: 'html-loader',
options: {
attrs: false,
},
},
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css',
}),
new WriteFilePlugin(),
// new CleanWebpackPlugin('dist', {}),
],
optimization: {
minimize: true,
},
watch: !isProduction,
devServer: {
port,
inline: false,
},
};
};