背景:当前项目首页和登陆后的平台在一个项目里,路由采用hash模式,现在要做SEO优化,这时候同构SSR(Server Side Rendering)服务端渲染代价显然太大,影响范围比较广,同样更改当前项目路由为history模式采用预渲染(Prerending)代价也不小。最终决定将首页单独出一个[……]
分类:Webpack
在vue中使用import()来代替require.ensure()实现代码打包分离
‘cross-env’ is not recognized as an internal or external command
webpack 3.8 使用 extract-text-webpack-plugin 3.0 抽取css失败:You may need an appropriate loader to handle this file type.
1 2 3 4 5 6 7 8 9 10 11 12 |
webpack 3.8.1 使用 extract-text-webpack-plugin 3.0.2 抽取css时失败,报错: ERROR in ./src/static/style/localTime.css Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type. | .localTimeBox { | color: red; | } @ ./node_modules/style-loader!./src/static/style/localTime.css 4:14-42 webpack-build.config.js 配置为: |
1 2 3 4 5 6 7 8 9 10 11 |
module: { loaders: [ { test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'style-loader!css-loader', {publicPath: '../'}) } ] }, plugins: [ new ExtractTextPlugin('css/bundle.min.css', {allChunks: true}) ] |
解决方法:
将webpack-build.config.js 配置改为:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
module: { loaders: [ { test: /\.css$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: ['css-loader'], publicPath: '../' }) } ] }, plugins: [ new ExtractTextPlugin('css/bundle.min.css', {allChunks: true}) ] |
问题就解决了。[……]