Webpack: output to 'static-test' for tests
This commit is contained in:
parent
f061954fdb
commit
655d5393a3
4 changed files with 19 additions and 24 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -21,3 +21,4 @@ yarn-error.log*
|
|||
!/static/instance/**.example
|
||||
!/static/instance/**.example.*
|
||||
!/static/instance/**.example/**
|
||||
/static-test
|
||||
|
|
|
@ -4,29 +4,23 @@ const { env } = require('process');
|
|||
const settings = {
|
||||
source_path: 'app',
|
||||
public_root_path: 'static',
|
||||
public_output_path: getPublicOutputPath(),
|
||||
test_root_path: 'static-test',
|
||||
cache_path: 'tmp/cache/webpacker',
|
||||
resolved_paths: [],
|
||||
static_assets_extensions: [ '.jpg', '.jpeg', '.png', '.tiff', '.ico', '.svg', '.gif', '.eot', '.otf', '.ttf', '.woff', '.woff2' ],
|
||||
extensions: [ '.mjs', '.js', '.sass', '.scss', '.css', '.module.sass', '.module.scss', '.module.css', '.png', '.svg', '.gif', '.jpeg', '.jpg' ],
|
||||
};
|
||||
|
||||
function getPublicOutputPath() {
|
||||
if (env.NODE_ENV === 'test') {
|
||||
return 'packs-test';
|
||||
}
|
||||
const outputDir = env.NODE_ENV === 'test' ? settings.test_root_path : settings.public_root_path;
|
||||
|
||||
return 'packs';
|
||||
}
|
||||
|
||||
function packsPath(path) {
|
||||
return join(settings.public_output_path, path);
|
||||
}
|
||||
const output = {
|
||||
path: join(__dirname, '..', outputDir),
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
settings,
|
||||
env: {
|
||||
NODE_ENV: env.NODE_ENV,
|
||||
},
|
||||
packsPath,
|
||||
output,
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const { join } = require('path');
|
||||
const { settings, packsPath } = require('../configuration');
|
||||
const { settings } = require('../configuration');
|
||||
|
||||
module.exports = {
|
||||
test: new RegExp(`(${settings.static_assets_extensions.join('|')})$`, 'i'),
|
||||
|
@ -9,9 +9,9 @@ module.exports = {
|
|||
options: {
|
||||
name(file) {
|
||||
if (file.includes(settings.source_path)) {
|
||||
return packsPath('media/[path][name]-[hash].[ext]');
|
||||
return 'packs/media/[path][name]-[hash].[ext]';
|
||||
}
|
||||
return packsPath('media/[folder]/[name]-[hash:8].[ext]');
|
||||
return 'packs/media/[folder]/[name]-[hash:8].[ext]';
|
||||
},
|
||||
context: join(settings.source_path),
|
||||
},
|
||||
|
|
|
@ -8,7 +8,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|||
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');
|
||||
const CopyPlugin = require('copy-webpack-plugin');
|
||||
const { UnusedFilesWebpackPlugin } = require('unused-files-webpack-plugin');
|
||||
const { env, settings, packsPath } = require('./configuration');
|
||||
const { env, settings, output } = require('./configuration');
|
||||
const rules = require('./rules');
|
||||
|
||||
module.exports = {
|
||||
|
@ -18,10 +18,10 @@ module.exports = {
|
|||
),
|
||||
|
||||
output: {
|
||||
filename: packsPath('js/[name]-[chunkhash].js'),
|
||||
chunkFilename: packsPath('js/[name]-[chunkhash].chunk.js'),
|
||||
hotUpdateChunkFilename: packsPath('js/[id]-[hash].hot-update.js'),
|
||||
path: join(__dirname, '..', 'static'),
|
||||
filename: 'packs/js/[name]-[chunkhash].js',
|
||||
chunkFilename: 'packs/js/[name]-[chunkhash].chunk.js',
|
||||
hotUpdateChunkFilename: 'packs/js/[id]-[hash].hot-update.js',
|
||||
path: output.path,
|
||||
publicPath: '/',
|
||||
},
|
||||
|
||||
|
@ -59,8 +59,8 @@ module.exports = {
|
|||
},
|
||||
),
|
||||
new MiniCssExtractPlugin({
|
||||
filename: packsPath('css/[name]-[contenthash:8].css'),
|
||||
chunkFilename: packsPath('css/[name]-[contenthash:8].chunk.css'),
|
||||
filename: 'packs/css/[name]-[contenthash:8].css',
|
||||
chunkFilename: 'packs/css/[name]-[contenthash:8].chunk.css',
|
||||
}),
|
||||
new AssetsManifestPlugin({
|
||||
integrity: false,
|
||||
|
@ -94,10 +94,10 @@ module.exports = {
|
|||
new CopyPlugin({
|
||||
patterns: [{
|
||||
from: join(__dirname, '../node_modules/twemoji/assets/svg'),
|
||||
to: join(__dirname, '../static/emoji'),
|
||||
to: join(output.path, 'emoji'),
|
||||
}, {
|
||||
from: join(__dirname, '../node_modules/emoji-datasource/img/twitter/sheets/32.png'),
|
||||
to: join(__dirname, '../static/emoji/sheet_13.png'),
|
||||
to: join(output.path, 'emoji/sheet_13.png'),
|
||||
}],
|
||||
options: {
|
||||
concurrency: 100,
|
||||
|
|
Loading…
Reference in a new issue