pleroma-fe/build/webpack.base.conf.js

128 lines
3.3 KiB
JavaScript
Raw Normal View History

2016-10-27 01:46:32 +11:00
var path = require('path')
var config = require('../config')
var utils = require('./utils')
var projectRoot = path.resolve(__dirname, '../')
2018-12-13 04:03:50 +11:00
var ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin')
var CopyPlugin = require('copy-webpack-plugin');
2022-03-17 07:02:44 +11:00
var { VueLoaderPlugin } = require('vue-loader')
2016-10-27 01:46:32 +11:00
var env = process.env.NODE_ENV
// check env & config/index.js to decide weither to enable CSS Sourcemaps for the
// various preprocessor loaders added to vue-loader at the end of this file
var cssSourceMapDev = (env === 'development' && config.dev.cssSourceMap)
var cssSourceMapProd = (env === 'production' && config.build.productionSourceMap)
var useCssSourceMap = cssSourceMapDev || cssSourceMapProd
var now = Date.now()
2016-10-27 01:46:32 +11:00
module.exports = {
entry: {
app: './src/main.js'
},
output: {
path: config.build.assetsRoot,
publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath,
filename: '[name].js'
},
2019-04-29 05:03:03 +10:00
optimization: {
splitChunks: {
chunks: 'all'
}
},
2016-10-27 01:46:32 +11:00
resolve: {
2022-03-17 07:02:44 +11:00
extensions: ['.js', '.jsx', '.vue'],
modules: [
path.join(__dirname, '../node_modules')
],
2016-10-27 01:46:32 +11:00
alias: {
2022-03-17 07:02:44 +11:00
'vue': '@vue/compat',
'static': path.resolve(__dirname, '../static'),
2016-10-27 01:46:32 +11:00
'src': path.resolve(__dirname, '../src'),
'assets': path.resolve(__dirname, '../src/assets'),
'components': path.resolve(__dirname, '../src/components')
}
},
module: {
2017-03-10 21:11:49 +11:00
noParse: /node_modules\/localforage\/dist\/localforage.js/,
rules: [
2016-10-27 01:46:32 +11:00
{
enforce: 'pre',
test: /\.(js|vue)$/,
2016-10-27 01:46:32 +11:00
include: projectRoot,
exclude: /node_modules/,
use: {
loader: 'eslint-loader',
options: {
formatter: require('eslint-friendly-formatter'),
sourceMap: config.build.productionSourceMap,
extract: true
}
}
2016-10-27 01:46:32 +11:00
},
{
test: /\.vue$/,
2022-03-17 07:02:44 +11:00
loader: 'vue-loader',
options: {
compilerOptions: {
2022-03-30 03:55:30 +11:00
isCustomElement(tag) {
if (tag === 'pinch-zoom') {
return true
}
return false
},
2022-03-17 07:02:44 +11:00
compatConfig: {
MODE: 2
}
}
}
2016-10-27 01:46:32 +11:00
},
{
2018-08-28 04:25:00 +10:00
test: /\.jsx?$/,
2016-10-27 01:46:32 +11:00
include: projectRoot,
exclude: /node_modules\/(?!tributejs)/,
use: 'babel-loader'
2016-10-27 01:46:32 +11:00
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
use: {
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
2016-10-27 01:46:32 +11:00
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
use: {
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
2016-10-27 01:46:32 +11:00
}
},
2016-10-27 01:46:32 +11:00
]
2018-12-13 04:03:50 +11:00
},
plugins: [
new ServiceWorkerWebpackPlugin({
entry: path.join(__dirname, '..', 'src/sw.js'),
filename: 'sw-pleroma.js'
}),
new VueLoaderPlugin(),
// This copies Ruffle's WASM to a directory so that JS side can access it
new CopyPlugin({
patterns: [
{
from: "node_modules/ruffle-mirror/*",
to: "static/ruffle",
flatten: true
},
],
options: {
concurrency: 100,
},
2018-12-13 04:03:50 +11:00
})
]
2016-10-27 01:46:32 +11:00
}