Comments (10)
srr.js 文件 var serverCompiler = webpack(serverWebpackConfig, (err, stats) => { if (err || stats.hasErrors()) { console.log(err) } console.log('success') });
打印出来的是success
bundle也能获取得到
node -v
v6.11.3
npm -v
3.10.10
from vue-skeleton-webpack-plugin.
webpack.skeleton.config.js
const { resolve } = require('path')
const nodeExternals = require('webpack-node-externals')
const ExtractTextPlugin = require("extract-text-webpack-plugin")
const glob = require('glob')
const entryJsList = {}
const entries = glob.sync('./src/skeleton/*/entry-skeleton.js')
for (const path of entries) {
const chunkName = path.slice('./src/skeleton/'.length, -'/entry-skeleton.js'.length)
entryJsList[chunkName] = resolve(__dirname, path)
}console.log(entryJsList)
module.exports = {
target: 'node',
devtool: false,
entry: entryJsList,
output: {
path: resolve(__dirname, 'dist'),
filename: 'static/js/[name].js',
libraryTarget: 'commonjs2'
},
resolve: {
extensions: ['.js', '.json', '.vue'],
alias: {
'~': resolve(__dirname, 'src'),
vue$: 'vue/dist/vue.esm.js'
}
},
module: {
rules: [
{
enforce: 'pre',
test: /.vue$/,
loader: 'eslint-loader',
exclude: /node_modules/
},
{
test: /.js$/,
exclude: /node_modules/,
use: ['babel-loader', 'eslint-loader']
},
{
test: /.vue$/,
loader: 'vue-loader',
options: {
loaders: {
sass: ExtractTextPlugin.extract({
use: 'css-loader!sass-loader',
fallback: 'vue-style-loader'
})
}
}
}
]
},
externals: nodeExternals({
whitelist: /.css$/
}),
plugins: []
}
from vue-skeleton-webpack-plugin.
解决了呢
from vue-skeleton-webpack-plugin.
CSS 样式文件是用 ExtractWebpackPlugin 从 JS 里提取出来的。而这个插件根据 Webpack 宿主环境 2.x或者3.x 也有两个对应的版本 2.x.x 和 3.x.x。
所以我们这个插件也需要根据项目的 Webpack 版本选择 0.x.x(Webpack 2) 或者 1.x.x(Webpack 3)。
否则可能存在以下的问题:
原项目已经安装了 2.x.x 的 ExtractWebpackPlugin,而安装这个插件时又安装了 3.x.x 的ExtractWebpackPlugin。这样两个版本的依赖同时存在,从 MemoryFS 里就找不着样式文件了。
不过这是插件早期存在的问题,现在通过 package.json 的 peerDependencies,安装插件时发现不匹配是会在控制台给出提示的。
from vue-skeleton-webpack-plugin.
@xiaobinwu 我也遇到一样的问题了,你怎么解决的呢? 按照作者给出的提示没搞定
from vue-skeleton-webpack-plugin.
按照作者提示,还是没有搞定
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
from vue-skeleton-webpack-plugin.
这个问题已经解决了,如果用 vue-cli 模板配置,注意把 vue-loader.conf.js 修改下,启用
ExtractTextPlugin
const utils = require('./utils')
const config = require('../config')
const isProduction = process.env.NODE_ENV === 'production'
module.exports = {
loaders: utils.cssLoaders({
sourceMap: isProduction
? config.build.productionSourceMap
: config.dev.cssSourceMap,
// extract: isProduction
extract: true
}),
transformToRequire: {
video: 'src',
source: 'src',
img: 'src',
image: 'xlink:href'
}
}
from vue-skeleton-webpack-plugin.
基于 vue-cli 配置,skeleton 会一闪而过,不知道什么原因
from vue-skeleton-webpack-plugin.
我知道什么原因了,服务渲染挂载需要修改
/* eslint-disable no-new */
// new Vue({
// el: '#app',
// router,
// store,
// loading,
// template: '<App/>',
// components: {
// App
// }
// })
let app = new Vue({
router,
store,
loading,
...App
})
router.onReady(() => {
store.commit('iniIsandroid')
store.commit('initClientHeight')
app.$mount('#app')
})
from vue-skeleton-webpack-plugin.
@jiangjunfeng98 把 vue-loader.conf.js 修改下,我上面已经回复了
from vue-skeleton-webpack-plugin.
Related Issues (20)
- vue、vue-server-renderer版本不匹配问题 HOT 2
- vue-cli3.0建的项目跑不起来 HOT 1
- IE浏览器,使用路由骨架屏不显示
- 关于vue-cli3 多skeleton 多路由的问题 HOT 7
- 通过路由A页面跳转B页面,B页面没有显示骨架屏结构,但是单独刷新B页面就会有骨架屏结构是为什么? HOT 3
- 页面什么时候加载骨架屏,什么时候加载真时的页面元素?骨架屏消失的短暂出白屏怎么修补? HOT 2
- 出现以下报错: window is not defined HOT 1
- 使用GBK打包,打包后骨架屏乱码,请问如何设置骨架屏的编码 HOT 1
- 开发模式下 编译报错throw new MemoryFileSystemError(errors.code.ENOENT, _path); Error: no such file or directory
- 该项目只支持骨架屏的webpack配置吗?生成骨架屏是怎么操作的?
- a._ssrList is not a function
- vue.cli3的main.js修改原来的代码为现在的作用是啥,能说下么,谢谢
- After using splitChunks, skeleton dom is not injected into index.html. HOT 1
- 怎么没有vue-cli3.0 MPA多页的例子
- vue-cli4安装后引用就报错 HOT 3
- html-webpack-plugin版本号4.0以上就报错
- npm run dev 未能生成骨架!
- Vue-cli4 不支持 HOT 1
- vue项目 虽然可以不同路由匹配不同skeleton,但是只能是初始页面刷新生效,页面中的路由跳转就不行了 HOT 3
- 总是报错”TypeError: Cannot read property 'render' of undefined“
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-skeleton-webpack-plugin.