[mobile] changed build script

This commit is contained in:
Maxim Kadushkin 2020-12-10 16:15:41 +03:00
parent afbfc7d095
commit 03ee826008
3 changed files with 23 additions and 19 deletions

View file

@ -2,7 +2,8 @@ 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 config = process.env.BUILD_EDITOR == 'slide' ? require('./webpack.config.pe.js') : require('./webpack.config.js'); const editor = process.env.TARGET_EDITOR;
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';

View file

@ -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/presentationeditor/mobile/src/app.js', app: `../../apps/${editor}/mobile/src/app.js`,
}, },
output: { output: {
path: resolvePath('../../apps/presentationeditor/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/presentationeditor/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/presentationeditor/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'),
@ -106,15 +108,7 @@ module.exports = {
publicPath: '../' publicPath: '../'
} }
}), }),
'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/presentationeditor/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/presentationeditor/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/presentationeditor/mobile/index.html', filename: `../../../apps/${editor}/mobile/index.html`,
template: '../../apps/presentationeditor/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,

View file

@ -12,7 +12,8 @@
"build-prod": "cross-env NODE_ENV=production node ./build/build.js", "build-prod": "cross-env NODE_ENV=production node ./build/build.js",
"postinstall": "cpy ./node_modules/framework7-icons/fonts/*.* ./src/fonts/", "postinstall": "cpy ./node_modules/framework7-icons/fonts/*.* ./src/fonts/",
"build-word": "cross-env NODE_ENV=development node ./build/build.js", "build-word": "cross-env NODE_ENV=development node ./build/build.js",
"build-slide": "cross-env NODE_ENV=development BUILD_EDITOR=slide node ./build/build.js" "build-slide": "cross-env NODE_ENV=development TARGET_EDITOR=slide node ./build/build.js",
"build-cell": "cross-env NODE_ENV=development TARGET_EDITOR=cell node ./build/build.js"
}, },
"browserslist": [ "browserslist": [
"Android >= 7", "Android >= 7",