105 lines
2.6 KiB
JavaScript
105 lines
2.6 KiB
JavaScript
const path = require('path');
|
|
const webpack = require('webpack');
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
const SymlinkWebpackPlugin = require('symlink-webpack-plugin');
|
|
const { VueLoaderPlugin } = require('vue-loader');
|
|
|
|
const ROOT = path.resolve(__dirname, '..');
|
|
const SRC = path.resolve(ROOT, 'src');
|
|
const DIST = path.resolve(ROOT, 'dist');
|
|
const LIB = path.resolve(ROOT, 'lib');
|
|
|
|
module.exports = (env, argv) => {
|
|
const mode = argv.mode || 'production';
|
|
const isDev = (mode === 'development');
|
|
|
|
return {
|
|
mode,
|
|
devtool: isDev ? 'inline-source-map' : false,
|
|
watch: isDev,
|
|
entry: {
|
|
app: path.resolve(SRC, 'app.js')
|
|
},
|
|
output: {
|
|
path: DIST,
|
|
filename: '[name].js',
|
|
publicPath: '../dist/'
|
|
},
|
|
module: {
|
|
rules: [{
|
|
test: /\.vue$/,
|
|
loader: 'vue-loader'
|
|
}, {
|
|
test: /\.js$/,
|
|
exclude: file => (/node_modules/.test(file) && !/\.vue\.js/.test(file)),
|
|
use: {
|
|
loader: 'babel-loader',
|
|
options: {
|
|
presets: ['@babel/preset-env']
|
|
}
|
|
}
|
|
}, {
|
|
test: /\.html$/i,
|
|
loader: 'html-loader'
|
|
}, {
|
|
test: /\.s[ac]ss$/i,
|
|
use: [
|
|
'vue-style-loader',
|
|
'css-loader',
|
|
{
|
|
loader: 'sass-loader',
|
|
options: {
|
|
implementation: require.resolve('sass'),
|
|
sourceMap: isDev
|
|
}
|
|
}
|
|
]
|
|
}, {
|
|
test: /\.css$/i,
|
|
use: ['vue-style-loader', 'css-loader']
|
|
}, {
|
|
test: /\.(png|svg|jpg|jpeg|gif)$/i,
|
|
type: 'asset',
|
|
parser: {
|
|
dataUrlCondition: {
|
|
maxSize: 1 * 1024
|
|
}
|
|
},
|
|
generator: {
|
|
filename: 'images/[name][ext]'
|
|
}
|
|
}]
|
|
},
|
|
plugins: [
|
|
new CopyWebpackPlugin({
|
|
patterns: [
|
|
{ from: path.resolve(LIB, 'index.php'), to: 'index.php' },
|
|
{ from: path.resolve(SRC, 'images', 'logo_black.png'), to: 'images' },
|
|
{ from: path.resolve(SRC, 'images', 'spot-logo-only.svg'), to: 'images' }
|
|
]
|
|
}),
|
|
new SymlinkWebpackPlugin([
|
|
{ origin: '../files/', symlink: 'files' },
|
|
{ origin: '../geo/', symlink: 'geo' },
|
|
{ origin: '../src/images/icons/', symlink: 'images/icons' }
|
|
]),
|
|
new CleanWebpackPlugin(),
|
|
new webpack.DefinePlugin({
|
|
__VUE_OPTIONS_API__: 'true',
|
|
__VUE_PROD_DEVTOOLS__: 'false',
|
|
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false'
|
|
}),
|
|
new VueLoaderPlugin()
|
|
],
|
|
resolve: {
|
|
extensions: ['.vue', '.scss', '...'],
|
|
alias: {
|
|
'@components': path.resolve(SRC, 'components'),
|
|
'@scripts': path.resolve(SRC, 'scripts'),
|
|
'@styles': path.resolve(SRC, 'styles')
|
|
}
|
|
}
|
|
};
|
|
};
|