Changeset View
Changeset View
Standalone View
Standalone View
assets/config/webpack.config.development.js
- This file was moved from swh/web/assets/config/webpack.config.development.js.
/** | /** | ||||
* Copyright (C) 2018-2020 The Software Heritage developers | * Copyright (C) 2018-2021 The Software Heritage developers | ||||
* See the AUTHORS file at the top-level directory of this distribution | * See the AUTHORS file at the top-level directory of this distribution | ||||
* License: GNU Affero General Public License version 3, or any later version | * License: GNU Affero General Public License version 3, or any later version | ||||
* See top-level LICENSE file for more information | * See top-level LICENSE file for more information | ||||
*/ | */ | ||||
// webpack configuration for compiling static assets in development mode | // webpack configuration for compiling static assets in development mode | ||||
// import required node modules and webpack plugins | // import required node modules and webpack plugins | ||||
Show All 16 Lines | |||||
const isDevServer = process.argv.find(v => v.includes('serve')) !== undefined; | const isDevServer = process.argv.find(v => v.includes('serve')) !== undefined; | ||||
// webpack-dev-server configuration | // webpack-dev-server configuration | ||||
const devServerPort = 3000; | const devServerPort = 3000; | ||||
const devServerPublicPath = 'http://localhost:' + devServerPort + '/static/'; | const devServerPublicPath = 'http://localhost:' + devServerPort + '/static/'; | ||||
// set publicPath according if we are using webpack-dev-server to serve | // set publicPath according if we are using webpack-dev-server to serve | ||||
// our assets or not | // our assets or not | ||||
const publicPath = isDevServer ? devServerPublicPath : '/static/'; | const publicPath = isDevServer ? devServerPublicPath : '/static/'; | ||||
const nodeModules = path.resolve(__dirname, '../../../../node_modules/'); | const nodeModules = path.resolve(__dirname, '../../node_modules/'); | ||||
// collect all bundles we want to produce with webpack | // collect all bundles we want to produce with webpack | ||||
var bundles = {}; | var bundles = {}; | ||||
const bundlesDir = path.join(__dirname, '../src/bundles'); | const bundlesDir = path.join(__dirname, '../src/bundles'); | ||||
fs.readdirSync(bundlesDir).forEach(file => { | fs.readdirSync(bundlesDir).forEach(file => { | ||||
bundles[file] = ['bundles/' + file + '/index.js']; | bundles[file] = ['bundles/' + file + '/index.js']; | ||||
// workaround for https://github.com/webpack/webpack-dev-server/issues/2692 | // workaround for https://github.com/webpack/webpack-dev-server/issues/2692 | ||||
if (isDevServer) { | if (isDevServer) { | ||||
Show All 24 Lines | options: { | ||||
'config': { | 'config': { | ||||
'extends': 'stylelint-config-standard', | 'extends': 'stylelint-config-standard', | ||||
'rules': { | 'rules': { | ||||
'indentation': 4, | 'indentation': 4, | ||||
'font-family-no-missing-generic-family-keyword': null, | 'font-family-no-missing-generic-family-keyword': null, | ||||
'no-descending-specificity': null | 'no-descending-specificity': null | ||||
}, | }, | ||||
'ignoreFiles': ['node_modules/**/*.css', | 'ignoreFiles': ['node_modules/**/*.css', | ||||
'swh/web/assets/src/thirdparty/**/*.css'] | 'assets/src/thirdparty/**/*.css'] | ||||
} | } | ||||
}], | }], | ||||
// automatically add vendor prefixes to css rules | // automatically add vendor prefixes to css rules | ||||
'autoprefixer', | 'autoprefixer', | ||||
'postcss-normalize', | 'postcss-normalize', | ||||
['postcss-reporter', { | ['postcss-reporter', { | ||||
clearReportedMessages: true | clearReportedMessages: true | ||||
}] | }] | ||||
▲ Show 20 Lines • Show All 311 Lines • ▼ Show 20 Lines | new webpack.ProvidePlugin({ | ||||
Util: 'exports-loader?Util!bootstrap/js/dist/util' | Util: 'exports-loader?Util!bootstrap/js/dist/util' | ||||
}), | }), | ||||
// needed in order to use pdf.js | // needed in order to use pdf.js | ||||
new webpack.IgnorePlugin(/^\.\/pdf.worker.js$/), | new webpack.IgnorePlugin(/^\.\/pdf.worker.js$/), | ||||
new CopyWebpackPlugin({ | new CopyWebpackPlugin({ | ||||
patterns: [ | patterns: [ | ||||
{ | { | ||||
from: path.resolve(nodeModules, 'pdfjs-dist/build/pdf.worker.min.js'), | from: path.resolve(nodeModules, 'pdfjs-dist/build/pdf.worker.min.js'), | ||||
to: path.resolve(__dirname, '../../../../static/js/') | to: path.resolve(__dirname, '../../static/js/') | ||||
}, | }, | ||||
{ | { | ||||
from: path.resolve(nodeModules, 'mathjax/es5/output/chtml/fonts/woff-v2/**'), | from: path.resolve(nodeModules, 'mathjax/es5/output/chtml/fonts/woff-v2/**'), | ||||
to: path.resolve(__dirname, '../../../../static/fonts/[name].[ext]') | to: path.resolve(__dirname, '../../static/fonts/[name].[ext]') | ||||
} | } | ||||
] | ] | ||||
}), | }), | ||||
new GenerateWebLabelsPlugin({ | new GenerateWebLabelsPlugin({ | ||||
outputType: 'json', | outputType: 'json', | ||||
exclude: ['mini-css-extract-plugin', | exclude: ['mini-css-extract-plugin', | ||||
'bootstrap-loader'], | 'bootstrap-loader'], | ||||
srcReplace: { | srcReplace: { | ||||
'./node_modules/pdfjs-dist/build/pdf.min.js': | './node_modules/pdfjs-dist/build/pdf.min.js': | ||||
'./node_modules/pdfjs-dist/build/pdf.js', | './node_modules/pdfjs-dist/build/pdf.js', | ||||
'./node_modules/admin-lte/dist/js/adminlte.min.js': | './node_modules/admin-lte/dist/js/adminlte.min.js': | ||||
'./node_modules/admin-lte/dist/js/adminlte.js' | './node_modules/admin-lte/dist/js/adminlte.js' | ||||
}, | }, | ||||
licenseOverride: { | licenseOverride: { | ||||
'./swh/web/assets/src/thirdparty/jquery.tabSlideOut/jquery.tabSlideOut.js': { | './assets/src/thirdparty/jquery.tabSlideOut/jquery.tabSlideOut.js': { | ||||
'spdxLicenseExpression': 'GPL-3.0', | 'spdxLicenseExpression': 'GPL-3.0', | ||||
'licenseFilePath': './swh/web/assets/src/thirdparty/jquery.tabSlideOut/LICENSE' | 'licenseFilePath': './assets/src/thirdparty/jquery.tabSlideOut/LICENSE' | ||||
} | } | ||||
}, | }, | ||||
additionalScripts: Object.assign( | additionalScripts: Object.assign( | ||||
{ | { | ||||
'js/pdf.worker.min.js': [ | 'js/pdf.worker.min.js': [ | ||||
{ | { | ||||
'id': 'pdfjs-dist/build/pdf.worker.js', | 'id': 'pdfjs-dist/build/pdf.worker.js', | ||||
'path': './node_modules/pdfjs-dist/build/pdf.worker.js', | 'path': './node_modules/pdfjs-dist/build/pdf.worker.js', | ||||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |