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

103 lines
2.7 KiB
JavaScript
Raw Permalink 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')
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
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'
},
resolve: {
extensions: ['', '.js', '.vue'],
fallback: [path.join(__dirname, '../node_modules')],
alias: {
2017-02-21 21:48:08 +11:00
'vue$': 'vue/dist/vue.runtime.common',
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')
}
},
resolveLoader: {
fallback: [path.join(__dirname, '../node_modules')]
},
module: {
2017-03-10 21:11:49 +11:00
noParse: /node_modules\/localforage\/dist\/localforage.js/,
2016-10-27 01:46:32 +11:00
preLoaders: [
{
test: /\.vue$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
},
{
test: /\.js$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
}
],
loaders: [
{
test: /\.vue$/,
loader: 'vue'
},
{
2018-08-28 04:25:00 +10:00
test: /\.jsx?$/,
2016-10-27 01:46:32 +11:00
loader: 'babel',
include: projectRoot,
exclude: /node_modules\/(?!tributejs)/
2016-10-27 01:46:32 +11:00
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url',
query: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url',
query: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
]
},
eslint: {
formatter: require('eslint-friendly-formatter')
},
vue: {
loaders: utils.cssLoaders({ sourceMap: useCssSourceMap }),
postcss: [
require('autoprefixer')({
browsers: ['last 2 versions']
})
]
2018-12-13 04:03:50 +11:00
},
plugins: [
new ServiceWorkerWebpackPlugin({
entry: path.join(__dirname, '..', 'src/sw.js'),
filename: 'sw-pleroma.js'
2018-12-13 04:03:50 +11:00
})
]
2016-10-27 01:46:32 +11:00
}