diff --git a/webpack/helpers.js b/webpack/helpers.js index fdc005f189..fb4dfc1165 100644 --- a/webpack/helpers.js +++ b/webpack/helpers.js @@ -1,13 +1,50 @@ const { - join, - resolve + join, + resolve, } = require('path'); + function root(path) { - return resolve(__dirname, '..', path); + return resolve(__dirname, '..', path); } +const theme = ''; +// const theme = 'mantis'; + +const globalCSSImports = [ + resolve(__dirname, '..', 'src/styles/_variables.scss'), + resolve(__dirname, '..', 'src/styles/_mixins.scss'), +]; + +const themeReplaceOptions = + { + multiple: [ + { + search: '$theme$.', + replace: theme + (theme.length ? '.' : ''), + + }, + { + search: '$themePath$/', + replace: (theme.length ? 'themes/' : ''), + + }, + { + search: '$theme$.', + replace: (theme.length ? theme + '.' : ''), + + }, + { + search: '$themePath$/', + replace: (theme.length ? 'themes/' : ''), + } + ] + }; + module.exports = { - root: root, - join: join + root: root, + join: join, + theme: theme, + globalCSSImports: globalCSSImports, + themeReplaceOptions: themeReplaceOptions }; diff --git a/webpack/webpack.common.js b/webpack/webpack.common.js index 4d8d3b77be..d6b273000b 100644 --- a/webpack/webpack.common.js +++ b/webpack/webpack.common.js @@ -2,40 +2,12 @@ const CopyWebpackPlugin = require('copy-webpack-plugin'); const path = require('path'); const { root, - join + join, + globalCSSImports, + themeReplaceOptions } = require('./helpers'); -// const theme = ''; -const theme = 'mantis'; -const globalCSSImports = [ - path.resolve(__dirname, '..', 'src/styles/_variables.scss'), - path.resolve(__dirname, '..', 'src/styles/_mixins.scss'), -]; -const themeReplaceOptions = - { - multiple: [ - { - search: '$theme$.', - replace: theme + (theme.length ? '.' : ''), - - }, - { - search: '$themePath$/', - replace: (theme.length ? 'themes/' : ''), - - }, - { - search: '$theme$.', - replace: (theme.length ? theme + '.' : ''), - - }, - { - search: '$themePath$/', - replace: (theme.length ? 'themes/' : ''), - } - ] - }; module.exports = { mode: 'development', devtool: 'source-map', diff --git a/webpack/webpack.server.js b/webpack/webpack.server.js index ce0c52602a..d2ac987d6c 100644 --- a/webpack/webpack.server.js +++ b/webpack/webpack.server.js @@ -1,7 +1,7 @@ var nodeExternals = require('webpack-node-externals'); const { - root + root } = require('./helpers'); module.exports = { @@ -12,7 +12,8 @@ module.exports = { output: { filename: 'server.js' }, - target: 'node', + module: {rules: []}, + target: 'node', externals: [nodeExternals({ whitelist: [ /@angular/, diff --git a/webpack/webpack.test.js b/webpack/webpack.test.js index 233fb2be57..03a9aefc0a 100644 --- a/webpack/webpack.test.js +++ b/webpack/webpack.test.js @@ -1,5 +1,7 @@ const { - root + root, + globalCSSImports, + themeReplaceOptions } = require('./helpers'); /** @@ -80,7 +82,11 @@ module.exports = function (options) { exclude: [/node_modules/], }, - + { + test: /\.component.ts$/, + loader: 'string-replace-loader', + options: themeReplaceOptions + }, /** * Typescript loader support for .ts and Angular 2 async routes via .async.ts * @@ -127,7 +133,6 @@ module.exports = function (options) { } } ], - exclude: [root('src/index.html')] }, /** @@ -136,39 +141,38 @@ module.exports = function (options) { * */ { - test: /\.scss$/, - use: [{ - loader: 'to-string-loader', - options: { - sourceMap: true - } - }, { - loader: 'raw-loader', - options: { - sourceMap: true - } - }, - { - loader: 'postcss-loader', - options: { - sourceMap: true - } - }, - { - loader: 'resolve-url-loader', - options: { - sourceMap: true - } - }, - { - loader: 'sass-loader', - options: { - sourceMap: true - } - }, - 'webpack-import-glob-loader' - ], - exclude: [root('src/index.html')] + test: /\.scss$/, + use: [ + { + loader: 'raw-loader', + options: { + sourceMap: true + } + }, + { + loader: 'resolve-url-loader', + options: { + sourceMap: true + } + }, + { + loader: 'sass-loader', + options: { + sourceMap: true + } + }, + { + loader: 'string-replace-loader', + options: themeReplaceOptions + }, + { + loader: 'sass-resources-loader', + options: { + resources: globalCSSImports + }, + }, + 'webpack-import-glob-loader' + ] }, /**