@alilc/build-plugin-alt
Version:
build-scripts plugin template for developers
78 lines (77 loc) • 2.83 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const setAssetsPath_1 = __importDefault(require("./setAssetsPath"));
const path = __importStar(require("path"));
const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
const webpack = __importStar(require("webpack"));
const is_wsl_1 = __importDefault(require("is-wsl"));
exports.default = (config, { pkg }) => {
(0, setAssetsPath_1.default)(config, { js: 'js', css: 'css' });
config.merge({
devServer: {
contentBase: path.join(__dirname, './public'),
logLevel: 'silent',
headers: {
'Access-Control-Allow-Origin': '*',
}
},
});
if (is_wsl_1.default) {
config.merge({
devServer: {
watchOptions: {
poll: 1000,
}
}
});
}
config
.plugin('index')
.use(html_webpack_plugin_1.default, [
{
inject: false,
templateParameters: {},
template: path.join(__dirname, './public/index.html'),
filename: 'index.html',
},
]);
config
.plugin('preview')
.use(html_webpack_plugin_1.default, [
{
inject: false,
templateParameters: {},
template: path.join(__dirname, './public/preview.html'),
filename: 'preview.html',
},
]);
config.plugins.delete('hot');
config.devServer.hot(false).disableHostCheck(true);
config.plugin('define').use(webpack.DefinePlugin, [{ PACKAGE_NAME: JSON.stringify(pkg.name) }]);
};