removed node env variable

This commit is contained in:
lotte
2019-06-05 14:25:58 +02:00
parent 5a47c2f4a7
commit ed128d1f17
8 changed files with 273 additions and 265 deletions

View File

@@ -157,7 +157,7 @@ module.exports = {
} }
}, },
theme: { theme: {
name: 'default', name: 'mantis',
cssClass: 'default', cssClass: 'mantis',
} }
}; };

View File

@@ -25,8 +25,8 @@
"prebuild:aot": "yarn run prebuild", "prebuild:aot": "yarn run prebuild",
"prebuild:prod": "yarn run prebuild", "prebuild:prod": "yarn run prebuild",
"build": "node ./scripts/webpack.js --progress --mode development", "build": "node ./scripts/webpack.js --progress --mode development",
"build:aot": "yarn run syncbuilddir && node ./scripts/resolve-absolute-scss-imports.js && DSPACE_BUILD_DIR=./build node ./scripts/webpack.js --env.aot --env.server --mode development && DSPACE_BUILD_DIR=./build node ./scripts/webpack.js --env.aot --env.client --mode development", "build:aot": "yarn run syncbuilddir && node ./scripts/resolve-absolute-scss-imports.js && node ./scripts/webpack.js --env.aot --env.server --mode development && node ./scripts/webpack.js --env.aot --env.client --mode development",
"build:prod": "yarn run syncbuilddir && node ./scripts/resolve-absolute-scss-imports.js && DSPACE_BUILD_DIR=./build node ./scripts/webpack.js --env.aot --env.server --mode production && DSPACE_BUILD_DIR=./build node ./scripts/webpack.js --env.aot --env.client --mode production", "build:prod": "yarn run syncbuilddir && node ./scripts/resolve-absolute-scss-imports.js && node ./scripts/webpack.js --env.aot --env.server --mode production && node ./scripts/webpack.js --env.aot --env.client --mode production",
"postbuild:prod": "yarn run rollup", "postbuild:prod": "yarn run rollup",
"rollup": "rollup -c rollup.config.js", "rollup": "rollup -c rollup.config.js",
"prestart": "yarn run build:prod", "prestart": "yarn run build:prod",

View File

@@ -1,15 +1,14 @@
const webpackMerge = require('webpack-merge'); const webpackMerge = require('webpack-merge');
const commonPartial = require('./webpack/webpack.common');
const clientPartial = require('./webpack/webpack.client');
const { getServerWebpackPartial } = require('./webpack/webpack.server');
const prodPartial = require('./webpack/webpack.prod'); const prodPartial = require('./webpack/webpack.prod');
const { module.exports = function (env, options) {
getAotPlugin
} = require('./webpack/webpack.aot');
module.exports = function(env, options) {
env = env || {}; env = env || {};
const commonPartial = require('./webpack/webpack.common')(env);
const clientPartial = require('./webpack/webpack.client')(env);
const {getAotPlugin} = require('./webpack/webpack.aot')(env);
const {getServerWebpackPartial} = require('./webpack/webpack.server')(env);
if (env.aot) { if (env.aot) {
console.log(`Running build for ${env.client ? 'client' : 'server'} with AoT Compilation`) console.log(`Running build for ${env.client ? 'client' : 'server'} with AoT Compilation`)
} }

View File

@@ -8,9 +8,10 @@ const projectRoot = (relativePath) => {
const srcPath = projectRoot('src'); const srcPath = projectRoot('src');
const buildRoot = (relativePath) => { const buildRoot = (relativePath, env) => {
if (process.env.DSPACE_BUILD_DIR) { console.log(env.aot);
return path.resolve(projectRoot(process.env.DSPACE_BUILD_DIR), relativePath); if (env.aot) {
return path.resolve(projectRoot('./build'), relativePath);
} else { } else {
return path.resolve(projectRoot('src'), relativePath); return path.resolve(projectRoot('src'), relativePath);
} }
@@ -58,10 +59,10 @@ else {
themePath = srcPath; themePath = srcPath;
} }
const globalCSSImports = [ const globalCSSImports = (env) => { return [
buildRoot('styles/_variables.scss'), buildRoot('styles/_variables.scss', env),
buildRoot('styles/_mixins.scss'), buildRoot('styles/_mixins.scss', env),
]; ]};
const themeReplaceOptions = const themeReplaceOptions =
{ {

View File

@@ -6,30 +6,32 @@ const {
AngularCompilerPlugin AngularCompilerPlugin
} = require('@ngtools/webpack'); } = require('@ngtools/webpack');
const tsconfigs = { module.exports = (env) => {
client: buildRoot('./tsconfig.browser.json'), const tsconfigs = {
server: buildRoot('./tsconfig.server.json') client: buildRoot('./tsconfig.browser.json', env),
}; server: buildRoot('./tsconfig.server.json', env)
};
const aotTsconfigs = { const aotTsconfigs = {
client: buildRoot('./tsconfig.browser.json'), client: buildRoot('./tsconfig.browser.json', env),
server: buildRoot('./tsconfig.server.aot.json') server: buildRoot('./tsconfig.server.aot.json', env)
}; };
/** /**
* Generates a AotPlugin for @ngtools/webpack * Generates a AotPlugin for @ngtools/webpack
* *
* @param {string} platform Should either be client or server * @param {string} platform Should either be client or server
* @param {boolean} aot Enables/Disables AoT Compilation * @param {boolean} aot Enables/Disables AoT Compilation
* @returns {AotPlugin} Configuration of AotPlugin * @returns {AotPlugin} Configuration of AotPlugin
*/ */
function getAotPlugin(platform, aot) { function getAotPlugin(platform, aot) {
return new AngularCompilerPlugin({ return new AngularCompilerPlugin({
tsConfigPath: aot ? aotTsconfigs[platform] : tsconfigs[platform], tsConfigPath: aot ? aotTsconfigs[platform] : tsconfigs[platform],
skipCodeGeneration: !aot skipCodeGeneration: !aot
}); });
} }
module.exports = { return {
getAotPlugin: getAotPlugin getAotPlugin: getAotPlugin
}
}; };

View File

@@ -6,15 +6,16 @@ const {
buildRoot buildRoot
} = require('./helpers'); } = require('./helpers');
module.exports = { module.exports = (env) => {
entry: buildRoot('./main.browser.ts'), return {
entry: buildRoot('./main.browser.ts', env),
output: { output: {
filename: 'client.js' filename: 'client.js'
}, },
target: 'web', target: 'web',
plugins: [ plugins: [
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
template: buildRoot('./index.html'), template: buildRoot('./index.html', env),
output: projectRoot('dist'), output: projectRoot('dist'),
inject: 'head' inject: 'head'
}), }),
@@ -22,4 +23,5 @@ module.exports = {
defaultAttribute: 'defer' defaultAttribute: 'defer'
}) })
] ]
}; };
}

View File

@@ -10,7 +10,8 @@ const {
themedUse themedUse
} = require('./helpers'); } = require('./helpers');
module.exports = { module.exports = (env) => {
return {
mode: 'development', mode: 'development',
devtool: 'source-map', devtool: 'source-map',
resolve: { resolve: {
@@ -68,8 +69,8 @@ module.exports = {
test: /\.scss$/, test: /\.scss$/,
exclude: [ exclude: [
/node_modules/, /node_modules/,
buildRoot('styles/_exposed_variables.scss'), buildRoot('styles/_exposed_variables.scss', env),
buildRoot('styles/_variables.scss') buildRoot('styles/_variables.scss', env)
], ],
use: [ use: [
{ {
@@ -100,7 +101,7 @@ module.exports = {
{ {
loader: 'sass-resources-loader', loader: 'sass-resources-loader',
options: { options: {
resources: globalCSSImports resources: globalCSSImports(env)
}, },
}, },
{ {
@@ -164,4 +165,5 @@ module.exports = {
} }
]) ])
] ]
}
}; };

View File

@@ -4,9 +4,10 @@ const {
buildRoot buildRoot
} = require('./helpers'); } = require('./helpers');
module.exports = { module.exports = (env) => {
return {
getServerWebpackPartial: function (aot) { getServerWebpackPartial: function (aot) {
const entry = aot ? buildRoot('./main.server.aot.ts') : buildRoot('./main.server.ts'); const entry = aot ? buildRoot('./main.server.aot.ts', env) : buildRoot('./main.server.ts', env);
return { return {
entry: entry, entry: entry,
output: { output: {
@@ -25,4 +26,5 @@ module.exports = {
})], })],
} }
} }
}
}; };