feat: allow specifying if platform is web or not
This commit is contained in:
@@ -2,7 +2,9 @@ const path = require('path');
|
|||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = (env = {
|
||||||
|
platform: 'web'
|
||||||
|
}) => ({
|
||||||
entry: './app/assets/javascripts/index.ts',
|
entry: './app/assets/javascripts/index.ts',
|
||||||
output: {
|
output: {
|
||||||
filename: './javascripts/app.js'
|
filename: './javascripts/app.js'
|
||||||
@@ -10,7 +12,7 @@ module.exports = {
|
|||||||
plugins: [
|
plugins: [
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
__VERSION__: JSON.stringify(require('./package.json').version),
|
__VERSION__: JSON.stringify(require('./package.json').version),
|
||||||
__PLATFORM_WEB__: JSON.stringify(true),
|
__PLATFORM_WEB__: JSON.stringify(env.platform === 'web'),
|
||||||
}),
|
}),
|
||||||
new MiniCssExtractPlugin({
|
new MiniCssExtractPlugin({
|
||||||
// Options similar to the same options in webpackOptions.output
|
// Options similar to the same options in webpackOptions.output
|
||||||
@@ -88,4 +90,4 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
const merge = require('webpack-merge');
|
const merge = require('webpack-merge');
|
||||||
const config = require('./webpack.config.js');
|
const config = require('./webpack.config.js');
|
||||||
|
|
||||||
module.exports = (_env, argv) => {
|
module.exports = (env, argv) => {
|
||||||
const port = argv.port || 3001;
|
const port = argv.port || 3001;
|
||||||
return merge(config, {
|
return merge(config(env, argv), {
|
||||||
mode: 'development',
|
mode: 'development',
|
||||||
devServer: {
|
devServer: {
|
||||||
publicPath: '/dist/',
|
publicPath: '/dist/',
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const merge = require('webpack-merge');
|
const merge = require('webpack-merge');
|
||||||
const config = require('./webpack.config.js');
|
const config = require('./webpack.config.js');
|
||||||
|
|
||||||
module.exports = merge(config, {
|
module.exports = (env, argv) => merge(config(env, argv), {
|
||||||
mode: 'production',
|
mode: 'production',
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user