|
|
@ -22,7 +22,7 @@ const imageOptions = {
|
|
|
|
limit: 10000,
|
|
|
|
limit: 10000,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function getWebpackConfig(modules) {
|
|
|
|
function getWebpackConfig(modules, esm = false) {
|
|
|
|
const pkg = require(getProjectPath('package.json'));
|
|
|
|
const pkg = require(getProjectPath('package.json'));
|
|
|
|
const babelConfig = require('./getBabelCommonConfig')(modules || false);
|
|
|
|
const babelConfig = require('./getBabelCommonConfig')(modules || false);
|
|
|
|
|
|
|
|
|
|
|
@ -185,7 +185,7 @@ All rights reserved.
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (process.env.RUN_ENV === 'PRODUCTION') {
|
|
|
|
if (process.env.RUN_ENV === 'PRODUCTION') {
|
|
|
|
const entry = ['./index'];
|
|
|
|
let entry = ['./index'];
|
|
|
|
config.externals = [
|
|
|
|
config.externals = [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
vue: {
|
|
|
|
vue: {
|
|
|
@ -197,9 +197,25 @@ All rights reserved.
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
];
|
|
|
|
config.output.library = distFileBaseName;
|
|
|
|
if (esm) {
|
|
|
|
|
|
|
|
entry = ['./index.esm'];
|
|
|
|
|
|
|
|
config.experiments = {
|
|
|
|
|
|
|
|
...config.experiments,
|
|
|
|
|
|
|
|
outputModule: true,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config.output.chunkFormat = 'module';
|
|
|
|
|
|
|
|
config.output.library = {
|
|
|
|
|
|
|
|
type: 'module',
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config.target = 'es2019';
|
|
|
|
|
|
|
|
} else {
|
|
|
|
config.output.libraryTarget = 'umd';
|
|
|
|
config.output.libraryTarget = 'umd';
|
|
|
|
|
|
|
|
config.output.library = distFileBaseName;
|
|
|
|
config.output.globalObject = 'this';
|
|
|
|
config.output.globalObject = 'this';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const entryName = esm ? `${distFileBaseName}.esm` : distFileBaseName;
|
|
|
|
|
|
|
|
|
|
|
|
config.optimization = {
|
|
|
|
config.optimization = {
|
|
|
|
minimizer: [
|
|
|
|
minimizer: [
|
|
|
|
new TerserPlugin({
|
|
|
|
new TerserPlugin({
|
|
|
@ -213,7 +229,7 @@ All rights reserved.
|
|
|
|
// Development
|
|
|
|
// Development
|
|
|
|
const uncompressedConfig = merge({}, config, {
|
|
|
|
const uncompressedConfig = merge({}, config, {
|
|
|
|
entry: {
|
|
|
|
entry: {
|
|
|
|
[distFileBaseName]: entry,
|
|
|
|
[entryName]: entry,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mode: 'development',
|
|
|
|
mode: 'development',
|
|
|
|
plugins: [
|
|
|
|
plugins: [
|
|
|
@ -226,7 +242,7 @@ All rights reserved.
|
|
|
|
// Production
|
|
|
|
// Production
|
|
|
|
const prodConfig = merge({}, config, {
|
|
|
|
const prodConfig = merge({}, config, {
|
|
|
|
entry: {
|
|
|
|
entry: {
|
|
|
|
[`${distFileBaseName}.min`]: entry,
|
|
|
|
[`${entryName}.min`]: entry,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mode: 'production',
|
|
|
|
mode: 'production',
|
|
|
|
plugins: [
|
|
|
|
plugins: [
|
|
|
|