openc3-cosmos-init/plugins/packages/openc3-cosmos-ace-diff/webpack.config.js
const path = require('path')
const isProduction = process.env.NODE_ENV == 'production'
// This removes the empty main.js that gets generated by webpack for the css files
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts')
const js_config = {
name: 'javascript',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'ace-diff.min.js',
library: {
type: 'commonjs-module',
},
},
module: {
rules: [
{
test: /\.(js|jsx)$/i,
loader: 'babel-loader',
},
],
},
}
const scss_config = {
name: 'scss',
entry: ['./src/styles/ace-diff.scss', './src/styles/ace-diff-dark.scss'],
module: {
rules: [
{
test: /\.scss$/,
exclude: /node_modules/,
use: [
{
loader: 'file-loader',
options: { name: '[name].min.css' },
},
// Compiles Sass to CSS
'sass-loader',
],
},
],
},
plugins: [new RemoveEmptyScriptsPlugin()],
}
module.exports = () => {
if (isProduction) {
js_config.mode = 'production'
scss_config.mode = 'production'
} else {
js_config.mode = 'development'
scss_config.mode = 'production'
}
return [js_config, scss_config]
}