diff --git a/webpack.config.js b/webpack.config.js index 0574c7650..bf2fe38d2 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,7 +2,9 @@ const path = require('path'); const webpack = require('webpack'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); -module.exports = { +module.exports = (env = { + platform: 'web' +}) => ({ entry: './app/assets/javascripts/index.ts', output: { filename: './javascripts/app.js' @@ -10,7 +12,7 @@ module.exports = { plugins: [ new webpack.DefinePlugin({ __VERSION__: JSON.stringify(require('./package.json').version), - __PLATFORM_WEB__: JSON.stringify(true), + __PLATFORM_WEB__: JSON.stringify(env.platform === 'web'), }), new MiniCssExtractPlugin({ // Options similar to the same options in webpackOptions.output @@ -88,4 +90,4 @@ module.exports = { } ] } -}; +}); diff --git a/webpack.dev.js b/webpack.dev.js index 92530e4ff..613d6a6fd 100644 --- a/webpack.dev.js +++ b/webpack.dev.js @@ -1,9 +1,9 @@ const merge = require('webpack-merge'); const config = require('./webpack.config.js'); -module.exports = (_env, argv) => { +module.exports = (env, argv) => { const port = argv.port || 3001; - return merge(config, { + return merge(config(env, argv), { mode: 'development', devServer: { publicPath: '/dist/', diff --git a/webpack.prod.js b/webpack.prod.js index 4cfcb6189..bd0750354 100644 --- a/webpack.prod.js +++ b/webpack.prod.js @@ -1,7 +1,7 @@ const merge = require('webpack-merge'); const config = require('./webpack.config.js'); -module.exports = merge(config, { +module.exports = (env, argv) => merge(config(env, argv), { mode: 'production', devtool: 'source-map', });