2018-03-07 14:28:48 +01:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
process.env.BABEL_ENV = 'web'
|
|
|
|
|
|
|
|
const path = require('path')
|
|
|
|
const webpack = require('webpack')
|
|
|
|
|
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
2018-11-12 15:54:39 +01:00
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
2018-03-07 14:28:48 +01:00
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
2018-11-12 15:54:39 +01:00
|
|
|
const { VueLoaderPlugin } = require('vue-loader')
|
2018-03-07 14:28:48 +01:00
|
|
|
|
|
|
|
let webConfig = {
|
|
|
|
entry: {
|
|
|
|
web: path.join(__dirname, '../src/renderer/main.js')
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.(js|vue)$/,
|
|
|
|
enforce: 'pre',
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'eslint-loader',
|
|
|
|
options: {
|
|
|
|
formatter: require('eslint-friendly-formatter')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-05-22 13:56:48 +02:00
|
|
|
{
|
|
|
|
test: /\.vue$/,
|
|
|
|
use: {
|
|
|
|
loader: 'vue-loader',
|
|
|
|
options: {
|
|
|
|
extractCSS: true,
|
|
|
|
loaders: {
|
|
|
|
sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax=1',
|
|
|
|
scss: 'vue-style-loader!css-loader!sass-loader',
|
|
|
|
less: 'vue-style-loader!css-loader!less-loader'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2018-11-12 15:54:39 +01:00
|
|
|
{
|
|
|
|
test: /\.scss$/,
|
|
|
|
use: ['vue-style-loader', 'css-loader', 'sass-loader']
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.sass$/,
|
|
|
|
use: ['vue-style-loader', 'css-loader', 'sass-loader?indentedSyntax']
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.less$/,
|
|
|
|
use: ['vue-style-loader', 'css-loader', 'less-loader']
|
|
|
|
},
|
2018-03-07 14:28:48 +01:00
|
|
|
{
|
|
|
|
test: /\.css$/,
|
2018-11-12 15:54:39 +01:00
|
|
|
use: ['vue-style-loader', 'css-loader']
|
2018-03-07 14:28:48 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.html$/,
|
|
|
|
use: 'vue-html-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
use: 'babel-loader',
|
2019-12-21 15:20:50 +01:00
|
|
|
include: [path.resolve(__dirname, '../src/renderer')],
|
2018-03-07 14:28:48 +01:00
|
|
|
exclude: /node_modules/
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
|
|
|
|
use: {
|
|
|
|
loader: 'url-loader',
|
2021-05-22 13:56:48 +02:00
|
|
|
options: {
|
2018-03-07 14:28:48 +01:00
|
|
|
limit: 10000,
|
|
|
|
name: 'imgs/[name].[ext]'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
|
|
|
|
use: {
|
|
|
|
loader: 'url-loader',
|
2021-05-22 13:56:48 +02:00
|
|
|
options: {
|
2018-03-07 14:28:48 +01:00
|
|
|
limit: 10000,
|
|
|
|
name: 'fonts/[name].[ext]'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
plugins: [
|
2018-11-12 15:54:39 +01:00
|
|
|
new VueLoaderPlugin(),
|
2019-12-21 15:20:50 +01:00
|
|
|
new MiniCssExtractPlugin({ filename: 'styles.css' }),
|
2018-03-07 14:28:48 +01:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
filename: 'index.html',
|
|
|
|
template: path.resolve(__dirname, '../src/index.ejs'),
|
|
|
|
minify: {
|
|
|
|
collapseWhitespace: true,
|
|
|
|
removeAttributeQuotes: true,
|
|
|
|
removeComments: true
|
|
|
|
},
|
|
|
|
nodeModules: false
|
|
|
|
}),
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env.IS_WEB': 'true'
|
|
|
|
}),
|
|
|
|
new webpack.HotModuleReplacementPlugin(),
|
|
|
|
new webpack.NoEmitOnErrorsPlugin()
|
|
|
|
],
|
|
|
|
output: {
|
|
|
|
filename: '[name].js',
|
|
|
|
path: path.join(__dirname, '../dist/web')
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'@': path.join(__dirname, '../src/renderer'),
|
2019-12-21 15:20:50 +01:00
|
|
|
vue$: 'vue/dist/vue.esm.js'
|
2018-03-07 14:28:48 +01:00
|
|
|
},
|
|
|
|
extensions: ['.js', '.vue', '.json', '.css']
|
|
|
|
},
|
|
|
|
target: 'web'
|
|
|
|
}
|
|
|
|
|
2021-05-22 14:50:45 +02:00
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
|
webConfig.devtool = 'eval-cheap-module-source-map'
|
|
|
|
}
|
|
|
|
|
2018-03-07 14:28:48 +01:00
|
|
|
/**
|
|
|
|
* Adjust webConfig for production settings
|
|
|
|
*/
|
|
|
|
if (process.env.NODE_ENV === 'production') {
|
2019-12-21 15:20:50 +01:00
|
|
|
webConfig.mode = 'production'
|
2018-03-07 14:28:48 +01:00
|
|
|
webConfig.plugins.push(
|
2020-05-27 17:45:42 +02:00
|
|
|
new CopyWebpackPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: path.join(__dirname, '../static'),
|
|
|
|
to: path.join(__dirname, '../dist/web/static'),
|
|
|
|
globOptions: {
|
|
|
|
ignore: ['.*', '*~']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}),
|
2018-03-07 14:28:48 +01:00
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env.NODE_ENV': '"production"'
|
|
|
|
}),
|
|
|
|
new webpack.LoaderOptionsPlugin({
|
|
|
|
minimize: true
|
|
|
|
})
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = webConfig
|