stremio-web/webpack.config.js

144 lines
5.2 KiB
JavaScript
Raw Normal View History

2018-06-04 12:56:17 +00:00
const path = require('path');
const webpack = require('webpack');
2018-06-04 12:56:17 +00:00
const HtmlWebPackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
2019-07-18 12:26:33 +00:00
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
2018-11-06 15:53:30 +00:00
const TerserPlugin = require('terser-webpack-plugin');
2018-06-04 12:56:17 +00:00
module.exports = {
entry: './src/index.js',
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
2018-06-04 12:56:17 +00:00
use: {
2018-11-06 15:53:30 +00:00
loader: 'babel-loader',
options: {
2019-07-18 11:45:15 +00:00
presets: [
'@babel/preset-env',
'@babel/preset-react'
],
2019-04-10 08:04:33 +00:00
plugins: [
'@babel/plugin-proposal-class-properties',
2019-04-16 07:27:37 +00:00
'@babel/plugin-proposal-object-rest-spread'
2019-04-10 08:04:33 +00:00
]
2018-11-06 15:53:30 +00:00
}
2018-06-04 12:56:17 +00:00
}
2018-06-04 14:38:28 +00:00
},
{
2018-06-05 08:49:35 +00:00
test: /\.less$/,
2018-06-04 14:38:28 +00:00
exclude: /node_modules/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
reloadAll: true
}
2018-06-04 14:38:28 +00:00
},
{
loader: 'css-loader',
options: {
2019-07-18 12:55:04 +00:00
importLoaders: 2,
modules: {
2019-09-11 13:35:29 +00:00
localIdentName: '[local]-[hash:base64:5]'
2019-07-18 12:55:04 +00:00
}
2018-06-12 14:44:22 +00:00
}
},
{
loader: 'postcss-loader',
options: {
ident: 'postcss-id',
plugins: () => [
2019-05-13 11:44:08 +00:00
require('cssnano')({
2019-07-18 11:45:15 +00:00
preset: [
'advanced',
{
autoprefixer: {
add: true,
remove: true,
2019-09-24 11:02:11 +00:00
flexbox: false,
grid: false
2019-07-18 11:45:15 +00:00
},
calc: false,
convertValues: false,
discardComments: {
removeAll: true,
},
discardOverridden: false,
mergeIdents: false,
normalizeDisplayValues: false,
normalizePositions: false,
normalizeRepeatStyle: false,
normalizeUnicode: false,
normalizeUrl: false,
reduceIdents: false,
reduceInitial: false,
zindex: false
}
]
2019-05-13 11:44:08 +00:00
})
2018-06-12 14:44:22 +00:00
]
2018-06-04 14:38:28 +00:00
}
2018-06-05 08:49:35 +00:00
},
{
loader: 'less-loader',
options: {
strictMath: true,
2019-09-15 05:27:57 +00:00
noIeCompat: true
2018-06-05 08:49:35 +00:00
}
2018-06-04 14:38:28 +00:00
}
]
2018-06-04 12:56:17 +00:00
}
]
},
2018-06-04 13:34:15 +00:00
resolve: {
2019-04-10 08:04:33 +00:00
extensions: ['.js', '.json', '.less', '.wasm'],
2018-06-04 13:34:15 +00:00
alias: {
2019-07-19 10:32:40 +00:00
'stremio': path.resolve(__dirname, 'src'),
'stremio-router': path.resolve(__dirname, 'src/router')
2018-06-04 13:34:15 +00:00
}
},
devServer: {
2018-11-07 14:14:04 +00:00
host: '0.0.0.0',
hot: false,
inline: false
},
2018-11-06 15:53:30 +00:00
optimization: {
minimizer: [
new TerserPlugin({
test: /\.js$/,
terserOptions: {
ecma: 5,
mangle: true,
warnings: true,
output: {
comments: false,
beautify: false,
wrap_iife: true
}
}
})
]
},
2018-06-04 12:56:17 +00:00
plugins: [
new webpack.ProgressPlugin(),
new CopyWebpackPlugin([
2019-09-13 12:52:37 +00:00
{ from: 'node_modules/stremio-core-web/static', to: '' },
{ from: 'images', to: 'images' },
{ from: 'fonts', to: 'fonts' }
2019-07-18 11:45:15 +00:00
]),
new HtmlWebPackPlugin({
template: './src/index.html',
inject: false
2019-07-18 12:26:33 +00:00
}),
2019-08-02 12:35:40 +00:00
new MiniCssExtractPlugin(),
2019-07-18 12:26:33 +00:00
new CleanWebpackPlugin({
verbose: true,
cleanOnceBeforeBuildPatterns: [],
2019-08-02 12:35:40 +00:00
cleanAfterEveryBuildPatterns: ['./main.js', './main.css']
2019-07-18 11:45:15 +00:00
})
2018-06-04 12:56:17 +00:00
]
2018-11-06 15:53:30 +00:00
};