[mobile] refactoring build scripts
This commit is contained in:
parent
f5d48e6492
commit
465ede2f4e
3
vendor/framework7-react/build/build.js
vendored
3
vendor/framework7-react/build/build.js
vendored
|
@ -2,8 +2,7 @@ const webpack = require('webpack');
|
||||||
const ora = require('ora');
|
const ora = require('ora');
|
||||||
const rm = require('rimraf');
|
const rm = require('rimraf');
|
||||||
const chalk = require('chalk');
|
const chalk = require('chalk');
|
||||||
const editor = process.env.TARGET_EDITOR;
|
const config = require('./webpack.config.js');
|
||||||
const config = !process.env.TARGET_EDITOR ? require('./webpack.config.js') : require('./webpack.config.pe.js');
|
|
||||||
|
|
||||||
const env = process.env.NODE_ENV || 'development';
|
const env = process.env.NODE_ENV || 'development';
|
||||||
const target = process.env.TARGET || 'web';
|
const target = process.env.TARGET || 'web';
|
||||||
|
|
34
vendor/framework7-react/build/webpack.config.js
vendored
34
vendor/framework7-react/build/webpack.config.js
vendored
|
@ -16,14 +16,16 @@ function resolvePath(dir) {
|
||||||
|
|
||||||
const env = process.env.NODE_ENV || 'development';
|
const env = process.env.NODE_ENV || 'development';
|
||||||
const target = process.env.TARGET || 'web';
|
const target = process.env.TARGET || 'web';
|
||||||
|
const editor = process.env.TARGET_EDITOR == 'cell' ? 'spreadsheeteditor' :
|
||||||
|
process.env.TARGET_EDITOR == 'slide' ? 'presentationeditor' : 'documenteditor';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
mode: env,
|
mode: env,
|
||||||
entry: {
|
entry: {
|
||||||
app: '../../apps/documenteditor/mobile/src/app.js',
|
app: `../../apps/${editor}/mobile/src/app.js`,
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
path: resolvePath('../../apps/documenteditor/mobile'), // path above depends on it
|
path: resolvePath(`../../apps/${editor}/mobile`), // path above depends on it
|
||||||
filename: 'dist/js/[name].js', // in such form will be injected in index.html
|
filename: 'dist/js/[name].js', // in such form will be injected in index.html
|
||||||
chunkFilename: 'dist/js/[name].js',
|
chunkFilename: 'dist/js/[name].js',
|
||||||
publicPath: '',
|
publicPath: '',
|
||||||
|
@ -33,7 +35,7 @@ module.exports = {
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.js', '.jsx', '.json'],
|
extensions: ['.js', '.jsx', '.json'],
|
||||||
alias: {
|
alias: {
|
||||||
'@': resolvePath('../../apps/documenteditor/mobile/src'),
|
'@': resolvePath(`../../apps/${editor}/mobile/src`),
|
||||||
},
|
},
|
||||||
modules: [path.resolve(__dirname, '..', 'node_modules'), 'node_modules'],
|
modules: [path.resolve(__dirname, '..', 'node_modules'), 'node_modules'],
|
||||||
},
|
},
|
||||||
|
@ -63,7 +65,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
include: [
|
include: [
|
||||||
resolvePath('../../apps/documenteditor/mobile/src'),
|
resolvePath(`../../apps/${editor}/mobile/src`),
|
||||||
resolvePath('../../apps/common/mobile/lib'),
|
resolvePath('../../apps/common/mobile/lib'),
|
||||||
resolvePath('node_modules/framework7'),
|
resolvePath('node_modules/framework7'),
|
||||||
|
|
||||||
|
@ -107,14 +109,6 @@ module.exports = {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
'css-loader',
|
'css-loader',
|
||||||
{
|
|
||||||
loader: "less-loader",
|
|
||||||
options: {
|
|
||||||
lessOptions: {
|
|
||||||
javascriptEnabled: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
loader: 'postcss-loader',
|
loader: 'postcss-loader',
|
||||||
options: {
|
options: {
|
||||||
|
@ -123,6 +117,14 @@ module.exports = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
loader: "less-loader",
|
||||||
|
options: {
|
||||||
|
lessOptions: {
|
||||||
|
javascriptEnabled: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -131,7 +133,7 @@ module.exports = {
|
||||||
options: {
|
options: {
|
||||||
limit: 10000,
|
limit: 10000,
|
||||||
name: 'images/[name].[ext]',
|
name: 'images/[name].[ext]',
|
||||||
outputPath: '../../../apps/documenteditor/mobile/dist',
|
outputPath: `../../../apps/${editor}/mobile/dist`,
|
||||||
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -141,7 +143,7 @@ module.exports = {
|
||||||
options: {
|
options: {
|
||||||
limit: 10000,
|
limit: 10000,
|
||||||
name: 'fonts/[name].[ext]',
|
name: 'fonts/[name].[ext]',
|
||||||
outputPath: '../../../apps/documenteditor/mobile/dist/assets',
|
outputPath: `../../../apps/${editor}/mobile/dist/assets`,
|
||||||
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -168,8 +170,8 @@ module.exports = {
|
||||||
]),
|
]),
|
||||||
// new CleanWebpackPlugin(),
|
// new CleanWebpackPlugin(),
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
filename: '../../../apps/documenteditor/mobile/index.html',
|
filename: `../../../apps/${editor}/mobile/index.html`,
|
||||||
template: '../../apps/documenteditor/mobile/src/index_dev.html',
|
template: `../../apps/${editor}/mobile/src/index_dev.html`,
|
||||||
inject: true,
|
inject: true,
|
||||||
minify: env === 'production' ? {
|
minify: env === 'production' ? {
|
||||||
collapseWhitespace: true,
|
collapseWhitespace: true,
|
||||||
|
|
203
vendor/framework7-react/build/webpack.config.pe.js
vendored
203
vendor/framework7-react/build/webpack.config.pe.js
vendored
|
@ -1,203 +0,0 @@
|
||||||
const webpack = require('webpack');
|
|
||||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
||||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
||||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
||||||
|
|
||||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
||||||
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin');
|
|
||||||
const TerserPlugin = require('terser-webpack-plugin');
|
|
||||||
const WorkboxPlugin = require('workbox-webpack-plugin');
|
|
||||||
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
function resolvePath(dir) {
|
|
||||||
return path.join(__dirname, '..', dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
const env = process.env.NODE_ENV || 'development';
|
|
||||||
const target = process.env.TARGET || 'web';
|
|
||||||
const editor = process.env.TARGET_EDITOR == 'cell' ? 'spreadsheeteditor' :
|
|
||||||
process.env.TARGET_EDITOR == 'slide' ? 'presentationeditor' : 'documenteditor';
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
mode: env,
|
|
||||||
entry: {
|
|
||||||
app: `../../apps/${editor}/mobile/src/app.js`,
|
|
||||||
},
|
|
||||||
output: {
|
|
||||||
path: resolvePath(`../../apps/${editor}/mobile`), // path above depends on it
|
|
||||||
filename: 'dist/js/[name].js', // in such form will be injected in index.html
|
|
||||||
chunkFilename: 'dist/js/[name].js',
|
|
||||||
publicPath: '',
|
|
||||||
hotUpdateChunkFilename: 'hot/hot-update.js',
|
|
||||||
hotUpdateMainFilename: 'hot/hot-update.json',
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
extensions: ['.js', '.jsx', '.json'],
|
|
||||||
alias: {
|
|
||||||
'@': resolvePath(`../../apps/${editor}/mobile/src`),
|
|
||||||
},
|
|
||||||
modules: [path.resolve(__dirname, '..', 'node_modules'), 'node_modules'],
|
|
||||||
},
|
|
||||||
watch: true,
|
|
||||||
watchOptions: {
|
|
||||||
aggregateTimeout: 600,
|
|
||||||
poll: 1000,
|
|
||||||
},
|
|
||||||
externals: {
|
|
||||||
jquery: 'jQuery'
|
|
||||||
},
|
|
||||||
|
|
||||||
devtool: env === 'production' ? 'source-map' : 'source-map',
|
|
||||||
optimization: {
|
|
||||||
minimizer: [new TerserPlugin({
|
|
||||||
sourceMap: true,
|
|
||||||
})],
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.(mjs|js|jsx)$/,
|
|
||||||
use: {
|
|
||||||
loader: 'babel-loader',
|
|
||||||
options: {
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
|
||||||
include: [
|
|
||||||
resolvePath(`../../apps/${editor}/mobile/src`),
|
|
||||||
resolvePath('../../apps/common/mobile/lib'),
|
|
||||||
resolvePath('node_modules/framework7'),
|
|
||||||
|
|
||||||
resolvePath('node_modules/framework7-react'),
|
|
||||||
|
|
||||||
resolvePath('node_modules/template7'),
|
|
||||||
resolvePath('node_modules/dom7'),
|
|
||||||
resolvePath('node_modules/ssr-window'),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
test: /\.css$/,
|
|
||||||
use: [
|
|
||||||
(env === 'development' ? 'style-loader' : {
|
|
||||||
loader: MiniCssExtractPlugin.loader,
|
|
||||||
options: {
|
|
||||||
publicPath: '../'
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
'css-loader',
|
|
||||||
{
|
|
||||||
loader: 'postcss-loader',
|
|
||||||
options: {
|
|
||||||
config: {
|
|
||||||
path: path.resolve(__dirname, '..'),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.less$/,
|
|
||||||
use: [
|
|
||||||
(env === 'development' ? 'style-loader' : {
|
|
||||||
loader: MiniCssExtractPlugin.loader,
|
|
||||||
options: {
|
|
||||||
publicPath: '../'
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
'css-loader',
|
|
||||||
{
|
|
||||||
loader: 'postcss-loader',
|
|
||||||
options: {
|
|
||||||
config: {
|
|
||||||
path: path.resolve(__dirname, '..'),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
loader: "less-loader",
|
|
||||||
options: {
|
|
||||||
lessOptions: {
|
|
||||||
javascriptEnabled: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
|
|
||||||
loader: 'url-loader',
|
|
||||||
options: {
|
|
||||||
limit: 10000,
|
|
||||||
name: 'images/[name].[ext]',
|
|
||||||
outputPath: `../../../apps/${editor}/mobile/dist`,
|
|
||||||
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
|
|
||||||
loader: 'url-loader',
|
|
||||||
options: {
|
|
||||||
limit: 10000,
|
|
||||||
name: 'fonts/[name].[ext]',
|
|
||||||
outputPath: `../../../apps/${editor}/mobile/dist/assets`,
|
|
||||||
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
new webpack.DefinePlugin({
|
|
||||||
'process.env.NODE_ENV': JSON.stringify(env),
|
|
||||||
'process.env.TARGET': JSON.stringify(target),
|
|
||||||
}),
|
|
||||||
|
|
||||||
...(env === 'production' ? [
|
|
||||||
new OptimizeCSSPlugin({
|
|
||||||
cssProcessorOptions: {
|
|
||||||
safe: true,
|
|
||||||
map: { inline: false },
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
new webpack.optimize.ModuleConcatenationPlugin(),
|
|
||||||
] : [
|
|
||||||
// Development only plugins
|
|
||||||
new webpack.HotModuleReplacementPlugin(),
|
|
||||||
new webpack.NamedModulesPlugin(),
|
|
||||||
]),
|
|
||||||
// new CleanWebpackPlugin(),
|
|
||||||
new HtmlWebpackPlugin({
|
|
||||||
filename: `../../../apps/${editor}/mobile/index.html`,
|
|
||||||
template: `../../apps/${editor}/mobile/src/index_dev.html`,
|
|
||||||
inject: true,
|
|
||||||
minify: env === 'production' ? {
|
|
||||||
collapseWhitespace: true,
|
|
||||||
removeComments: true,
|
|
||||||
removeRedundantAttributes: true,
|
|
||||||
removeScriptTypeAttributes: true,
|
|
||||||
removeStyleLinkTypeAttributes: true,
|
|
||||||
useShortDoctype: true
|
|
||||||
} : false,
|
|
||||||
}),
|
|
||||||
new MiniCssExtractPlugin({
|
|
||||||
filename: 'css/[name].css',
|
|
||||||
}),
|
|
||||||
new CopyWebpackPlugin({
|
|
||||||
patterns: [
|
|
||||||
{
|
|
||||||
noErrorOnMissing: true,
|
|
||||||
from: resolvePath('src/static'),
|
|
||||||
to: resolvePath('www/static'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
noErrorOnMissing: true,
|
|
||||||
from: resolvePath('src/manifest.json'),
|
|
||||||
to: resolvePath('www/manifest.json'),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
};
|
|
Loading…
Reference in a new issue