mirror of https://github.com/artf/grapesjs.git
3 changed files with 65 additions and 34 deletions
@ -1,35 +1,50 @@ |
|||||
const path = require('path'); |
const path = require('path'); |
||||
const rootDir = path.resolve(__dirname); |
const rootDir = path.resolve(__dirname); |
||||
|
|
||||
module.exports = ({ config, pkg, webpack }) => ({ |
module.exports = ({ config, pkg, webpack }) => { |
||||
...config, |
const { BUILD_MODULE } = process.env; |
||||
output: { |
|
||||
...config.output, |
return { |
||||
filename: 'grapes.min.js', |
...config, |
||||
// This will assign all exports to the global object
|
output: { |
||||
library: undefined, |
...config.output, |
||||
}, |
filename: BUILD_MODULE ? 'grapes.mjs' : 'grapes.min.js', |
||||
devServer: { |
...(BUILD_MODULE ? { |
||||
...config.devServer, |
libraryTarget: 'module', |
||||
static: [rootDir], |
library: { type: 'module' }, |
||||
headers: { 'Access-Control-Allow-Origin': '*' }, |
} : { |
||||
allowedHosts: 'all', |
libraryExport: 'default' |
||||
}, |
}) |
||||
resolve: { |
}, |
||||
...config.resolve, |
optimization: { |
||||
modules: [ |
...config.optimization, |
||||
...(config.resolve && config.resolve.modules), |
minimize: !BUILD_MODULE, |
||||
'src' |
}, |
||||
], |
devServer: { |
||||
alias: { |
...config.devServer, |
||||
...(config.resolve && config.resolve.alias), |
static: [rootDir], |
||||
jquery: 'utils/cash-dom', |
headers: { 'Access-Control-Allow-Origin': '*' }, |
||||
backbone: `${rootDir}/node_modules/backbone`, |
allowedHosts: 'all', |
||||
underscore: `${rootDir}/node_modules/underscore`, |
}, |
||||
} |
experiments: { |
||||
}, |
outputModule: !!BUILD_MODULE, |
||||
plugins: [ |
}, |
||||
new webpack.DefinePlugin({ __GJS_VERSION__: `'${pkg.version}'` }), |
resolve: { |
||||
...config.plugins, |
...config.resolve, |
||||
] |
modules: [ |
||||
}); |
...(config.resolve && config.resolve.modules), |
||||
|
'src' |
||||
|
], |
||||
|
alias: { |
||||
|
...(config.resolve && config.resolve.alias), |
||||
|
jquery: 'utils/cash-dom', |
||||
|
backbone: `${rootDir}/node_modules/backbone`, |
||||
|
underscore: `${rootDir}/node_modules/underscore`, |
||||
|
} |
||||
|
}, |
||||
|
plugins: [ |
||||
|
new webpack.DefinePlugin({ __GJS_VERSION__: `'${pkg.version}'` }), |
||||
|
...config.plugins, |
||||
|
] |
||||
|
} |
||||
|
}; |
||||
|
|||||
Loading…
Reference in new issue