代码拉取完成,页面将自动刷新
const webpack = require('webpack');
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const nodeEnv = process.env.NODE_ENV || 'development';
const isProd = nodeEnv === 'production';
function createExternals() {
// Some libraries, e.g. those with native addons, cannot be bundled
// by webpack. Adding them as externals so that they are not bundled.
const libs = [
'pc-ble-driver-js',
'pc-nrfjprog-js',
'serialport',
'usb',
'nrf-device-setup',
'osx-temperature-sensor',
];
return libs.reduce(
(prev, lib) => Object.assign(prev, { [lib]: `commonjs ${lib}` }),
{}
);
}
module.exports = {
mode: nodeEnv,
devtool: isProd ? 'hidden-source-map' : 'inline-eval-cheap-source-map',
entry: {
app: './src/app',
shared: './node_modules/pc-nrfconnect-shared/src/index.js',
launcher: './src/launcher',
},
output: {
path: path.resolve('dist'),
publicPath: '../dist/',
filename: '[name]-bundle.js',
},
module: {
rules: [
{
test: /\.(js|jsx|ts|tsx)$/,
use: [
{
loader: require.resolve('babel-loader'),
options: {
cacheDirectory: true,
configFile:
'./node_modules/pc-nrfconnect-shared/config/babel.config.js',
},
},
{
loader: require.resolve('eslint-loader'),
},
],
exclude: /node_modules\/(?!pc-nrfconnect-shared\/)/,
},
{
test: /\.scss|\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'sass-loader',
options: {
// eslint-disable-next-line global-require
implementation: require('sass'),
},
},
],
},
{
test: /\.(png|gif|ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
loader: require.resolve('file-loader'),
},
],
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
symlinks: false,
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(nodeEnv),
}),
new MiniCssExtractPlugin({
// The next line is only needed as long as we still need to support legacy apps.
// Later, when we want to drop support for legacy apps, just replace that line with
// filename: '[name].css',
moduleFilename: ({ name }) =>
name === 'app' ? 'legacy.css' : '[name].css',
chunkFilename: '[id].css',
}),
],
externals: createExternals(),
target: 'electron-renderer',
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。