sexdevil / lsloader Goto Github PK
View Code? Open in Web Editor NEWlocalStorage loader to increase mobile webapp speed
localStorage loader to increase mobile webapp speed
webpack.config.js存在冲突 无法启动
//webpack.config.js
"use strict";
var webpack = require('webpack');
var fs = require('fs');
//步骤一 对源码分析 提取公共模块依赖关系
require('./webpackPlugin/lsloader_complier').run()
var entryPath = './webpack_lsloader_entry.json';
var entryString = fs.readFileSync(entryPath, 'utf8');
var entry = JSON.parse(entryString);
var ManifestPlugin = require('webpack-manifest-plugin');
var manifestPlugin = new ManifestPlugin({
publicPath: '/webpack2/',
});
//步骤二 webpack打包中的chunkID mouduleID都稳定为路径ID
var ChunkIDsByFilePath = require('./webpackPlugin/chunkIDsByFilePath');
var chunkIDsByFilePath = new ChunkIDsByFilePath();
var ModuleIDbyFilePath = require('./webpackPlugin/moduleIDbyFilePath');
var moduleIDbyFilePath = new ModuleIDbyFilePath();
<<<<<<< HEAD
var afterEmitAddFileSeprate = require('./webpackPlugin/afterEmitAddFileSeprate');
var afteremitaddfileSeprate = new afterEmitAddFileSeprate();
//自定义拆分列表数组
let commonChunksListString = fs.readFileSync('./gulptask/webpack2/build/commonChunksConfig.json', 'utf8');
=======
//步骤三 步骤一中提取的依赖关系拼接到commonChunksPlugin配置里,用官方插件分割
let commonChunksListString = fs.readFileSync('./webpackPlugin/build/commonChunksConfig.json', 'utf8');
>>>>>>> a770c24cfbc18d1d21c5a2a32822747f24a0b3f6
commonChunksListString = JSON.parse(commonChunksListString);
let commonChunksList = [];
for(var i in commonChunksListString){
commonChunksList.push(new webpack.optimize.CommonsChunkPlugin(commonChunksListString[i]))
}
//步骤五 打包结束后每个js加上/*combojs*/文件分割符,线上combo用
let AddComboPlugin = require('./webpackPlugin/lsloader_addcombo')
let addComboPlugin = new AddComboPlugin();
//步骤四 打包
module.exports = {
//插件项
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name:'common',
filename : 'common_[chunkhash].js'
}),
manifestPlugin,
chunkIDsByFilePath,
moduleIDbyFilePath,
<<<<<<< HEAD
new webpack.HashedModuleIdsPlugin(),
afteremitaddfileSeprate
=======
//步骤五 打包结束后每个js加上/*combojs*/文件分割符,线上combo用
addComboPlugin,
new webpack.HashedModuleIdsPlugin()
>>>>>>> a770c24cfbc18d1d21c5a2a32822747f24a0b3f6
].concat(commonChunksList),
//页面入口文件配置
entry: entry,
//入口文件输出配置
output: {
path: __dirname+'/build/webpack2',
filename: 'page_[name]_[chunkhash].js'
},
module: {
//加载器配置
loaders: [
{ test: /\.css$/, loader: 'style-loader!css-loader' },
{
test: /\.js$/,
loader: 'babel-loader',
exclude: function(path) {
// 路径中含有 node_modules 的就不去解析。
var isNpmModule = !!path.match(/node_modules/);
return isNpmModule;
}
},
{ test: /\.scss$/, loader: 'style!css!sass?sourceMap'},
{ test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192'},
{ test: /\.vue$/, loader: 'vue-loader'}
]
},
watch: false
}
1,请问依赖分析是针对uglify之后的代码吗?我看astbuild里貌似是require了uglify,不是acorn
2,ast之后,如何一一匹配 模块id和js绝对路径? 不同项目的路径不一样,涉及发布测试环境和真实上线路径,感觉很麻烦啊
很抱歉,我用git下载代码到本地后 npm install 无法把全部依赖下载下来,并且单独把报错的依赖包下载下来后,依然没有成功打包出来一个demo出来,希望维护者能够解答一下或者提供一个最小可运行demo.谢谢。
本地环境:
node v9.11.1
npm 5.6.0
希望基于 webpack 提供一整套方案,不依赖 gulp
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.