Simplify building script
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
const path = require('path')
|
||||
|
||||
module.exports = {
|
||||
SRC: path.resolve(__dirname, '..', 'src'),
|
||||
DIST: path.resolve(__dirname, '..', 'dist'),
|
||||
ASSETS: path.resolve(__dirname, '..', 'assets'),
|
||||
IMAGES: path.resolve(__dirname, '..', 'src/images'),
|
||||
STYLES: path.resolve(__dirname, '..', 'src/styles'),
|
||||
LIB: path.resolve(__dirname, '..', 'lib'),
|
||||
MASKS: path.resolve(__dirname, '..', 'src/masks'),
|
||||
ROOT: path.resolve(__dirname, '..')
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
const path = require('path');
|
||||
const { SRC, DIST, LIB } = require('./paths');
|
||||
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')
|
||||
|
||||
module.exports = {
|
||||
entry: {
|
||||
app: path.resolve(SRC, 'scripts', '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: /\.(woff|woff2|eot|ttf|otf)$/i,
|
||||
type: 'asset/resource'
|
||||
}, {
|
||||
test: /\.s[ac]ss$/i,
|
||||
use: [
|
||||
'vue-style-loader',
|
||||
'css-loader',
|
||||
'resolve-url-loader',
|
||||
{
|
||||
loader: 'sass-loader',
|
||||
options: {
|
||||
implementation: require.resolve('sass'),
|
||||
sourceMap: true
|
||||
}
|
||||
}
|
||||
]
|
||||
}, {
|
||||
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: 'src/images/logo_black.png', to: 'images' },
|
||||
{ from: '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: ['.js', '.vue', '...'],
|
||||
alias: {
|
||||
"@scripts": path.resolve(SRC, "scripts")
|
||||
}
|
||||
}
|
||||
};
|
||||
102
build/webpack.config.js
Normal file
102
build/webpack.config.js
Normal file
@@ -0,0 +1,102 @@
|
||||
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, 'scripts', '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: ['.js', '.vue', '...'],
|
||||
alias: {
|
||||
'@scripts': path.resolve(SRC, 'scripts')
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -1,7 +0,0 @@
|
||||
const { merge } = require('webpack-merge')
|
||||
|
||||
module.exports = merge(require('./webpack.common.js'), {
|
||||
mode: 'development',
|
||||
devtool: 'inline-source-map',
|
||||
watch: true
|
||||
})
|
||||
@@ -1,5 +0,0 @@
|
||||
const { merge } = require('webpack-merge')
|
||||
|
||||
module.exports = merge(require('./webpack.common.js'), {
|
||||
mode: 'production'
|
||||
})
|
||||
Reference in New Issue
Block a user