Refactor to use a base webpack for statics, for both dev & prod

pull/16234/head
Víctor Velarde 4 years ago
parent 364a53c83f
commit 098154434f

@ -0,0 +1,35 @@
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const webpackFiles = require('../../lib/build/files/webpack_files');
const Package = require('./../../package.json');
const VERSION = Package.version;
module.exports = {
entry: Object.assign(
{ main: './lib/assets/javascripts/dashboard/statics/static.js' },
webpackFiles.gearEntryPoints
),
output: {
filename: `${VERSION}/javascripts/[name].js`,
path: path.resolve(__dirname, '../../public/assets'),
publicPath: '/assets/'
},
devtool: 'source-map',
plugins: [
new webpack.DefinePlugin({
__ASSETS_VERSION__: `'${VERSION}'`
}),
...Object.keys(webpackFiles.htmlFiles).map((entryName) => {
return new HtmlWebpackPlugin({
inject: false,
cache: false,
filename: webpackFiles.htmlFiles[entryName].filename || path.resolve(__dirname, `../../public/static/${entryName}/index.html`),
template: path.resolve(__dirname, '../../lib/assets/javascripts/dashboard/statics/index.jst.ejs'),
config: webpackFiles.htmlFiles[entryName]
});
})
]
};

@ -1,32 +1,6 @@
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const webpackFiles = require('../../lib/build/files/webpack_files');
const Package = require('./../../package.json');
const merge = require('webpack-merge');
const baseConfig = require('./webpack.base.config.js');
const VERSION = Package.version;
module.exports = {
entry: './lib/assets/javascripts/dashboard/statics/static.js',
output: {
filename: `${VERSION}/javascripts/[name].js`,
path: path.resolve(__dirname, '../../public/assets'),
publicPath: '/assets/'
},
devtool: 'source-map',
plugins: [
new webpack.DefinePlugin({
__ASSETS_VERSION__: `'${VERSION}'`
}),
...Object.keys(webpackFiles.htmlFiles).map((entryName) => {
return new HtmlWebpackPlugin({
inject: false,
cache: false,
filename: webpackFiles.htmlFiles[entryName].filename || path.resolve(__dirname, `../../public/static/${entryName}/index.html`),
template: path.resolve(__dirname, '../../lib/assets/javascripts/dashboard/statics/index.jst.ejs'),
config: webpackFiles.htmlFiles[entryName]
});
})
]
};
module.exports = merge(baseConfig, {
mode: 'development'
});

@ -1,35 +1,6 @@
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const webpackFiles = require('../../lib/build/files/webpack_files');
const Package = require('./../../package.json');
const merge = require('webpack-merge');
const baseConfig = require('./webpack.base.config.js');
const VERSION = Package.version;
module.exports = {
entry: Object.assign(
{ main: './lib/assets/javascripts/dashboard/statics/static.js' },
webpackFiles.gearEntryPoints
),
output: {
filename: `${VERSION}/javascripts/[name].js`,
path: path.resolve(__dirname, '../../public/assets'),
publicPath: '/assets/'
},
devtool: 'source-map',
plugins: [
new webpack.DefinePlugin({
__ASSETS_VERSION__: `'${VERSION}'`
}),
...Object.keys(webpackFiles.htmlFiles).map((entryName) => {
return new HtmlWebpackPlugin({
inject: false,
cache: false,
filename: webpackFiles.htmlFiles[entryName].filename || path.resolve(__dirname, `../../public/static/${entryName}/index.html`),
template: path.resolve(__dirname, '../../lib/assets/javascripts/dashboard/statics/index.jst.ejs'),
config: webpackFiles.htmlFiles[entryName]
});
})
]
};
module.exports = merge(baseConfig, {
mode: 'production'
});

Loading…
Cancel
Save