Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何引入公共的样式或js? #38

Closed
pangao66 opened this issue Nov 27, 2017 · 6 comments
Closed

如何引入公共的样式或js? #38

pangao66 opened this issue Nov 27, 2017 · 6 comments
Labels

Comments

@pangao66
Copy link

如果在每个页面都引入一段相同的css 或js代码? 在每个页面 的app.js里面引入每次都要写一遍.
以及html里面如何引入静态文件? 目前html里面用link或者script标签方式引入都路径不对 ,vue-cli那样可以直接在index.html里面引入static目录下的文件.

@AlanSean
Copy link

AlanSean commented Nov 28, 2017

下载 并配置 copy-webpack-plugin
就可以了写link或者script引入的时候写相对路径(看你如何配置了)

@Plortinus
Copy link
Owner

Plortinus commented Nov 29, 2017

项目中,我都是建好一个文件目录,然后无限复制,这样就变相的引入公共样式...
静态文件,就得靠copy-webpack-plugin这个插件了

@AlanSean
Copy link

你是直接在page里面写了一个css文件夹l来进行引用?

@Plortinus
Copy link
Owner

公共样式文件我是写在assets目录下,然后在app.js里引用

@AlanSean
Copy link

我现在遇到的问题就是
link问题 html里面写了link引入assets里面清除默认样式的文件 ExtractTextPlugin会报错
很搞不懂 我已经copy了 难道ExtractTextPlugin也需要设置忽略某些文件吗 刚研究第三天 很揪心

@AlanSean
Copy link

现在又遇到的问题 我只写了一个html vue js 文件 然后打包会Cannot read property 'call' of undefined
这是为啥 是因为CommonsChunkPlugin 必须两个页面以上才可以吗 但是在线运行是没问题的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants