Saturday, May 11, 2024
 Popular · Latest · Hot · Upcoming
34
rated 0 times [  37] [ 3]  / answers: 1 / hits: 58854  / 9 Years ago, tue, march 10, 2015, 12:00:00

Is it possible to include external file with webpack (outside the context) and make the file included in built output bundle.js?



consider this setup where sub-app is context for webpack:




  • /sub-app/entry.js

  • /bower-components/zepto/zepto.js



And webpack config with broccoli:



var webpackify = require('broccoli-webpack');
var path = require('path');
var webpack = require(webpack);

var bundler = webpackify(path.resolve('sub-app'), {
entry: './entry',
output: {filename: './bundle.js'},
devtool: 'eval',

module: {
loaders: [
{test: /.js$/, loader: 'babel-loader'},
{test: /.hbs$/, loader: handlebars-loader}
]
},
plugins: [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin()
]
});


I would like to include zepto.js in output bundle.js. But I need to preserve bower_components outside the sub-app.


More From » webpack

 Answers
14

Ok found answer myself. No special adjustments are necessary. Only include external file in code with relative path:



In my case:



import zepto from './../bower_components/zepto/zepto.js';

[#67501] Sunday, March 8, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
yesseniadajab

Total Points: 258
Total Questions: 101
Total Answers: 127

Location: Mexico
Member since Mon, Sep 12, 2022
2 Years ago
yesseniadajab questions
Tue, Aug 3, 21, 00:00, 3 Years ago
Fri, Jan 15, 21, 00:00, 3 Years ago
Thu, Dec 10, 20, 00:00, 3 Years ago
;