notebook/webpack.config.js

77 lines
2.4 KiB
JavaScript
Raw Normal View History

2016-02-05 04:12:19 +08:00
var _ = require('underscore');
var path = require('path');
var commonConfig = {
resolve: {
root: [
'.', /* allows npm packages to be loaded */
'./notebook/static'
].map(x =>path.resolve(x)),
modulesDirectories: [
"components", /* bower */
"node_modules" /* npm */
]
},
module: {
loaders: [
{ test: /\.css$/, loader: "style-loader!css-loader" },
{ test: /\.json$/, loader: "json-loader" },
// jquery-ui loads some images
{ test: /\.(jpg|png|gif)$/, loader: "file" },
// required to load font-awesome
{ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=application/font-woff" },
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=application/font-woff" },
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=application/octet-stream" },
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file" },
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=image/svg+xml" }
]
},
externals: {
jquery: '$',
bootstrap: '$',
bootstraptour: 'Tour',
'jquery-ui': '$',
typeahead: '$.typeahead'
2016-02-05 04:12:19 +08:00
}
};
function buildConfig(appName) {
2016-02-05 08:54:09 +08:00
if (typeof appName !== 'string') return appName;
2016-02-05 04:12:19 +08:00
return _.extend({}, commonConfig, {
entry: './notebook/static/' + appName + '/js/main.js',
2016-02-05 08:54:09 +08:00
output: {
filename: 'main.min.js',
2016-02-05 04:12:19 +08:00
path: './notebook/static/' + appName + '/js/built',
2016-02-05 08:54:09 +08:00
publicPath: "/static/" + appName + "/js/built/"
},
devtool: 'source-map',
2016-02-05 04:12:19 +08:00
});
}
module.exports = [
'auth',
'edit',
'terminal',
'tree',
2016-02-05 08:54:09 +08:00
'notebook',
_.extend({}, commonConfig, {
entry: './notebook/static/services/contents.js',
output: {
filename: 'contents.js',
path: './notebook/static/services/built',
libraryTarget: 'amd'
},
devtool: 'source-map',
}),
_.extend({}, commonConfig, {
entry: './notebook/static/index.js',
output: {
filename: 'index.js',
path: './notebook/static/built',
libraryTarget: 'amd',
publicPath: "/static/built/"
},
devtool: 'source-map',
}),
2016-02-05 04:12:19 +08:00
].map(x => buildConfig(x));